title: Binding WPF Datagrid cell background colour with trigger
body: <p>I want the background colour of a WPF datagrid cell to change colour when the contents have been modified. Each cell has behind it a ViewModel object which contains the following properties - Value, OriginalValue and Modified. When the user edits the cell contents, this automatically triggers the Amount property via data binding. This property setter then checks it against the original value and sets the boolean Modified property to true or false respectively, notifies the bindings for those properties to update.</p>
  
  <p>I have so far achieved a partial result with a Style on the ElementStyle property of the DataGridTextColumn as follows</p>
  
  <pre><code>&lt;Style x:Key="DataGridTextStyle" TargetType="{x:Type TextBlock}"&gt;
      &lt;Style.Triggers&gt;
          &lt;DataTrigger Binding="{Binding Path=MyViewModel.Modified}" Value="True"&gt;
              &lt;Setter Property="Background" Value="Yellow"/&gt;
          &lt;/DataTrigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>This updates the text content background colour, but that is only a small area in the center of the cell. I want the entire cell to updates it's background colour, not just the textblock attribute.</p>
  
  <p>Can I modify the above trigger to search upwards in the visual tree to find a parent DataGridCell and set the Background property on that, rather than setting the background colour of the current textblock only?</p>