title: How to apply nested Styles from ResourceDictionary in WPF?
body: <p>I use a DataGrid (WPF 4.0) control. The style for it is placed in a ResourceDictionary and contains a nested Style element:</p>
  
  <pre><code>&lt;Style x:Key="MyDataGridStyle" TargetType="{x:Type controls:DataGrid}"&gt;
      &lt;Setter Property="Background" Value="Black"/&gt;
      &lt;Setter Property="CellStyle"&gt;
          &lt;Setter.Value&gt;
              &lt;Style TargetType="{x:Type DataGridCell}"&gt;
                  &lt;Setter Property="BorderThickness" Value="0" /&gt;
                  &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
              &lt;/Style&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Here, only the Background style is applied. The CellStyle NOT.</p>
  
  <p>It only works when I define the CellStyle directly inside the <code>DataGrid</code> element:</p>
  
  <pre><code>&lt;DataGrid Style="{StaticResource MyDataGridStyle}"&gt;
         &lt;DataGrid.CellStyle&gt;
              &lt;Style TargetType="{x:Type DataGridCell}"&gt;
                  &lt;Setter Property="BorderThickness" Value="0" /&gt;
                  &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
              &lt;/Style&gt;
         &lt;/DataGrid.CellStyle&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Any ideas why?</p>
  
  <p><strong>Update</strong></p>
  
  <p>It seems that there is a problem when mixing styles with PresentationFramework.Aero theme that I have referenced in my ResourceDictionary. If I remove the reference it works!</p>