title: WPF DataGrid cell style from different property in XAML
body: <p>Is it possible to bind a data grid column value to one property of the bound class specified in ItemsSource, but reference a different property in that class to style the cell?</p>
  
  <p>Here is a code example:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="MyCollection"&gt;
    &lt;DataGridTextColumn Header="MyColumn" Binding={Binding ColumnText} /&gt;
    &lt;DataGridTextColumn Header="MyColumn2" Binding={Binding ColumnText2} /&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Suppose that I have a two further properties (Enum or Brush) in the objects in MyCollection that I want to refer to to set the background colour of the respective cells; can this be done?</p>
  
  <p>EDIT - I need to do this for multiple columns, each looking at a different property to ascertain the colour it should be; I have added a second column to the code example above.</p>
  
  <p>I know I can set the style based on the value in ColumnText, but that is not what I need to do.</p>
  
  <p>I have tried setting a style data trigger, but when I try to bind, I can only bind to something from the overall data context, not to another property within the object that is populating the current row.</p>
  
  <p>Many thanks!</p>