title: WPF change cell background color based on content
body: <p>I having difficulties trying to change a cell background color based on an Unbound's field (with non-simple backend structure) underneath structure.
  Here is the sample "complex" structure:</p>
  
  <pre><code>public class TestTable
  {
      public int order { get; set; }
      public TestMember t1 { get; set; }
      public TestMember t2 { get; set; }
      public TestMember t3 { get; set; }
  }
  
  public class TestMember
  {
      public TestMember(String i)
      {
          value = i;
      }
  
      public String value { get; set; }
  
  }
  </code></pre>
  
  <p>and this is the XAML:</p>
  
  <pre><code>&lt;igDP:XamDataGrid Name="xamDataGrid1"&gt;
  
          &lt;igDP:XamDataGrid.ViewSettings&gt;
              &lt;igDP:GridViewSettings UseNestedPanels="False"/&gt;
          &lt;/igDP:XamDataGrid.ViewSettings&gt;
  
          &lt;igDP:XamDataGrid.FieldSettings&gt;
              &lt;igDP:FieldSettings AllowRecordFiltering="true" FilterLabelIconDropDownType="MultiSelectExcelStyle" 
                                                          AllowEdit="False" AllowFixing="No" AllowSummaries="True"/&gt;
          &lt;/igDP:XamDataGrid.FieldSettings&gt;
  
          &lt;igDP:XamDataGrid.FieldLayoutSettings&gt;
              &lt;igDP:FieldLayoutSettings AutoGenerateFields="False" FilterUIType="LabelIcons" 
                                                                HeaderPrefixAreaDisplayMode="FieldChooserButton" AllowClipboardOperations="All"
                                                                CopyFieldLabelsToClipboard="True" AddNewRecordLocation="OnTopFixed"
                                                                AllowAddNew="False" HighlightAlternateRecords="False" ExpansionIndicatorDisplayMode="Never"
                                            /&gt;
          &lt;/igDP:XamDataGrid.FieldLayoutSettings&gt;
          &lt;igDP:XamDataGrid.FieldLayouts&gt;
              &lt;igDP:FieldLayout Key="Layout0"&gt;
                  &lt;igDP:FieldLayout.SortedFields&gt;
                      &lt;igDP:FieldSortDescription  FieldName="order" Direction="Ascending"&gt;&lt;/igDP:FieldSortDescription&gt;
                  &lt;/igDP:FieldLayout.SortedFields&gt;
                  &lt;igDP:FieldLayout.Fields&gt;
                      &lt;igDP:Field Name="order" Label="Ordinamento" AllowGroupBy="False"  Visibility="Collapsed" FixedLocation="FixedToNearEdge"/&gt;
                      &lt;igDP:UnboundField BindingMode="TwoWay" BindingPath="t1.value" Name="value" AllowEdit="True" Label="Anno Recoil" AllowGroupBy="False"  FixedLocation="FixedToNearEdge"/&gt;
                      &lt;igDP:UnboundField BindingMode="TwoWay" BindingPath="t2.value" Name="value" AllowEdit="True" Label="APC"  FixedLocation="FixedToNearEdge"/&gt;
                      &lt;igDP:UnboundField BindingMode="TwoWay" BindingPath="t3.value" Name="value" Label="R1" AllowEdit="True" FixedLocation="FixedToNearEdge"/&gt;
                  &lt;/igDP:FieldLayout.Fields&gt;
              &lt;/igDP:FieldLayout&gt;
          &lt;/igDP:XamDataGrid.FieldLayouts&gt;
  
      &lt;/igDP:XamDataGrid&gt;
  </code></pre>
  
  <p>What I'd like to get is a colored Grid the cells are black only when the root value is null, not when the leaf value is null. <a href="https://i.stack.imgur.com/0XlT0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0XlT0.png" alt="Colored XamDataGrid"></a></p>
  
  <p>The shown grid is the result of generating the second column rows a new TestMember with the value set to null.
  I'd like them to not be colored Black and treated differently.
  I've tired this converter:</p>
  
  <pre><code>&lt;igDP:XamDataGrid.Resources&gt;
          &lt;Style TargetType="{x:Type igDP:CellValuePresenter}"&gt;
              &lt;Setter Property="Background"&gt;
                  &lt;Setter.Value&gt;
                      &lt;MultiBinding Converter="{StaticResource BackGroundConverter}"&gt;
                          &lt;Binding RelativeSource="{RelativeSource Self}" Path="Value" /&gt;
                          &lt;Binding RelativeSource="{RelativeSource Self}" Path="DataContext"/&gt;
                          &lt;Binding RelativeSource="{RelativeSource Self}" /&gt;
                          &lt;Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
      &lt;/igDP:XamDataGrid.Resources&gt;
  </code></pre>
  
  <p>And what happens is that the CellValuePresenter passed to the multivalue converter has no field attached when the leaf value is null so I can't find an elegant way to retrieve in which column the value is null (either by root being null or leaf being null) and create a logic to color the cell in a proper way.</p>
  
  <p>Thanks in advance, leave a comment if I didn't explain properly the issue.</p>
  
  <p>Thanks again.</p>