Reputation: 1215
2 Questions :
Thanks very much
Joe
Edit (can't seem to reply)
Thanks alex, NVM
Regarding the Toggling Transparency, as long as I can set the 'Background' property of the Window at runtime from a color to 'Transparent' at that runtime, thats fine.
Regarding switching styles, just extending your code alex, presumably I can do something like
void OnButtonPress()
{
var transparentStyle = Themes.CurrentTheme.MyDGNonTransparentStyle;
var nonTransparentStyle = Themes.CurrentTheme.MyDGNonTransparentStyle;
if (isTransparent) // Change to Non-Transparent
this.MyGrid.Style = (Style)this.FindResource(nonTransparentStyle);
else // Change to Transparent
this.MyGrid.Style = (Style)this.FindResource(nonTransparentStyle);
}
?
Thanks
Joe
3rd Edit
Thanks guys,
Sorry to confuse you - my second question was since my datagrid has its own style (and doesn't inherit from the window) I will need to set its style depending on the current state (Transparent / Non-ransparent) - so I need to change the datagrid style at runtime - now since this can be done with a window, can I assume it can be done with a datagrid?
Thanks
Joe
Upvotes: 0
Views: 1912
Reputation: 3397
Is it possible to Toggle Transparency on a WPF window?
Yes, it is:
<Window WindowStyle="None"
AllowsTransparency="True"
Background="#88aa3366">
</Window/>
The bad news is that you have to implement the logic of window header by yourself. This article might be helpfull.
in the xaml code behind can I switch Styles?
The question is a little bit unclear, maybe this helps:
var key = Themes.CurrentTheme.MyDGStyle;
this.MyGrid.Style = (Style)this.FindResource(key);
Upvotes: 2