Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Cell Style for a Dynamic Table (dynamic columns) Based on the cell value
posted
I'm binding a XamDataGrid to a table that is created dynamically  (AutoGenerateFields="True").  
Each cell contains an object with info to know if the Foreground must be red or not 
(number of columns can change but cells will always contains the same type of object). 
 So I was” thinking” to write a converter to change the foreground, however what I get is the DataItem, 
and the DataItem is a DataRow and I don’t know how to get the value of “current” cell in the converter.
 
<igDP:XamDataGrid.Resources>                    
   <Style TargetType="{x:Type igDP:CellValuePresenter}">
        <Setter Property="Foreground" 
             Value="{Binding DataItem (I don’t know the cell),
                Converter={StaticResource colorDiffenceItemConverter}}" />
   </Style>
</igDP:XamDataGrid.Resources>
 
<igDP:XamDataGrid.FieldLayoutSettings>
      <igDP:FieldLayoutSettings AutoGenerateFields="True" 
                HighlightAlternateRecords="True" />
</igDP:XamDataGrid.FieldLayoutSettings>
 
<igDP:XamDataGrid.FieldLayouts>
     <igDP:FieldLayout>
         <igDP:Field Name="Name" Label="{x:Static res:….}" />
         <igDP:Field Name="AreEquals" 
                      Label="AreEquals" Visibility="Collapsed"/>
     </igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>

 

 

 

So, what I need to know is: In a table where the columns are created dynamically, How can I change the foreground of a cell based on a property of  the object in the cell.

 

 

|Colum 0 | Colum 1| Colum 2| Colum 3| Colum 4|

|{1, true} |{1, true} |{1, False} |{1, true} |{1, False} |

 

So it should display

 

|Colum 0 | Colum 1| Colum 2| Colum 3| Colum 4|

|      1        |       1        |      1           |     1         |1               |

 

Thanks,

Henry,