How do I define the default background color for window instances in a shared ResourceDictionary?

Posted by Nicholas on Stack Overflow See other posts from Stack Overflow or by Nicholas
Published on 2011-01-09T19:36:17Z Indexed on 2011/01/09 19:53 UTC
Read the original article Hit count: 187

Filed under:
|
|
|
|

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.

<Style TargetType="{x:Type Window}">
    <Setter Property="Background" Value="{DynamicResource MainColor}" />
</Style>

This syntax works on a type of Button, but is completely ignored for Window.

What am I doing wrong? Is there something special I have to do for a Window type.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml