I can't seem to set a default background color for all of my windows in my application. Does anyone know how to do this?
Currently I'm setting a theme in my App.xaml file like this.
<Application>
<Application.Resources>
<ResourceDictionary Source="Themes/SomeTheme.xaml" />
This basically styles my entire application.
Inside of SomeTheme.xaml
I am trying to set a default color for all of my windows like this.
<SolidColorBrush Color="{DynamicResource MainColor}" x:Key="CommonBackgroundBrush" />
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="{DynamicResource CommonBackgroundBrush}" />
</Style>
This syntax is completely ignored for derivatives of type Window
.
Is there some way to force the style to apply to all derivatives of Window
?
The weird thing about this syntax, is that it actually shows the correct color in the VS design preview window.
Your windows are not instances of Window
, they are instances of classes derived from Window
. So I think you will have to list them all, but you can use BasedOn
to help.