title: WPF Themeing of windows background dynamically
body: <p>Ok, I'm working on an application that will allow you to switch themes at runtime.  So far so good with all the controls and what not.  However my Window object will not apply any of the base items.  Here is an example of the xaml from one of my resource dictionaries.</p>
  
  <pre><code>&lt;SolidColorBrush x:Key="GrayBrush" Color="Gray" /&gt;
  &lt;SolidColorBrush x:Key="OrangeBrush" Color="Orange" /&gt;
  
  &lt;!-- Window Styles --&gt;
  &lt;Style TargetType="{x:Type Window}"&gt;
      &lt;Setter Property="Background" Value="{DynamicResource GrayBrush}" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>I have my primary theme which has the above snippet in my app.xaml resource list as well.  Now when the app starts the background is not applied nor when I change the resource dictionaries at runtime.  I figure I am either missing something or it just don't work.</p>
  
  <p>I'm using .net 3.5 and I'm just using the standard window object from the framework so I'm not inheriting from any other base control.  What I'm trying to do is keep from having to specify a style or other attribute on the window object as I'm also allowing you to switch to the included themes like Aero, Luna, Classic, etc.  </p>
  
  <p>I just cannot for the life of me get the window to use the style.</p>
  
  <p>The only thing that works, but does not change when switched, is if I set either a Style or Background attribute which is what I don't want to do.</p>
  
  <p>Also, when I change themes this is how it's done:</p>
  
  <pre><code>Application.Current.Resources.MergedDictionaries.Clear();
  Application.Current.Resources.MergedDictionaries.Add(dictionary);
  </code></pre>
  
  <p>The dictionary is a resource dictionary loaded based on the theme selected from either the .net stuff or my own.  This all appears to work fine just cannot get the window to work.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>Any thoughts.</p>
  
  <p>UPDATE: What I really want is a way for the Window object to change without having to change or set any additional properties on the window.  It kind of defeats the purpose if I have to add a style tag or what not to all the window objects in my app.</p>