title: WPF window style not being applied
body: <p>I have a ResourceDictionary that contains Style definitions for controls used within my application.</p>
  
  <p>All of the styles are applied properly to the controls in the window...but the style in the ResourceDictionary for the window itself is not being applied.</p>
  
  <p>This is the XAML in my ResourceDictionary that contains the style that I want to apply to my window:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:primatives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
      &lt;Style TargetType="{x:Type Window}"&gt;
          &lt;Setter Property="Background" Value="#FF121212"&gt;&lt;/Setter&gt;
          &lt;Setter Property="Height" Value="768"&gt;&lt;/Setter&gt;
          &lt;Setter Property="Width" Value="1024"&gt;&lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;!-- .... --&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>This is the XAML for the window that I am working with (trying to get this style to apply):</p>
  
  <pre><code>&lt;Window x:Class="TryingStyles"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="TryingStyles"&gt;
      &lt;Window.Resources&gt;
          &lt;ResourceDictionary&gt;
              &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="Resources/StylesDictionary.xaml" /&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/Window.Resources&gt;    
      &lt;StackPanel&gt;
          &lt;StackPanel Orientation="Horizontal"&gt;
              &lt;Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Label1" VerticalAlignment="Top" /&gt;
              &lt;TextBox Height="23" HorizontalAlignment="Left" Margin="56,14,0,0" Name="TextBox1" VerticalAlignment="Top" Width="120" /&gt;
          &lt;/StackPanel&gt;
          &lt;StackPanel Orientation="Horizontal"&gt;
              &lt;TabControl Height="206" HorizontalAlignment="Left" Margin="12,43,0,0" Name="TabControl1" VerticalAlignment="Top" Width="250"&gt;
                  &lt;TabItem Header="TabItem1" Name="TabItem1"&gt;
                      &lt;Grid&gt;&lt;/Grid&gt;
                  &lt;/TabItem&gt;
              &lt;/TabControl&gt;
              &lt;GroupBox Header="GroupBox1" Margin="268,43,12,12" Width="396"&gt;&lt;/GroupBox&gt;
          &lt;/StackPanel&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>It appears that the style for the window is applied when I view the window in the IDE's "Design view" but when I run the application the style is not applied.</p>
  
  <p>Does anyone know what I'm doing wrong?</p>