title: Styling Selected Cells in the WPF DataGrid Control
body: <p>I am trying to change the style for selected cells the WPF DataGrid control.</p>
  
  <p>What is the difference between styling <code>DataGridCell</code> and <code>DataGridRow</code>?  I tried various combinations below and they all work.  However, it seems like I only need to style <strong>either</strong> <code>DataGridCell</code> or <code>DataGridRow</code>.</p>
  
  <p>What is the purpose of having <strong>both</strong>?  This tells me I am misunderstanding their purpose.</p>
  
  <p>Style for <code>DataGridCell</code>: (in my own code, I change the colors from the defaults)</p>
  
  <pre><code> &lt;Style TargetType="{x:Type DataGridCell}"&gt;
   &lt;Style.Triggers&gt;
    &lt;Trigger Property="IsSelected" Value="True"&gt;
    &lt;Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt;
    &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/&gt;
    &lt;Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt;
    &lt;/Trigger&gt;
   &lt;/Style.Triggers&gt;
   &lt;/Style&gt;
  </code></pre>
  
  <p>Style for <code>DataGridRow</code>: (in my own code, I change the colors from the defaults)</p>
  
  <pre><code> &lt;Style TargetType="{x:Type DataGridRow}"&gt;
   &lt;Style.Triggers&gt;
    &lt;Trigger Property="IsSelected" Value="True"&gt;
    &lt;Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt;
    &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/&gt;
    &lt;Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt;
    &lt;/Trigger&gt;
   &lt;/Style.Triggers&gt;
   &lt;/Style&gt;
  </code></pre>