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
5124
How to style a cell background based on another cell value in XamDataGrid
posted

This question was recently answered in a private support case, and I thought I'd share it here in the forums:

Q:  How to style a cell background based on another cell value in XamDataGrid?
A:  A DataTrigger can be used to achieve this. The following example demonstrates highlighting the cell background of a given Field, based on the cell value in the first column that contains '1'.
** Style definition:
<Style x:Key="labelStyle" TargetType="{x:Type igDP:CellValuePresenter}">
                <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=Cells[0].Value}" Value="1">
                                <Setter Property="Background" Value="Yellow"/>
                </DataTrigger>
                </Style.Triggers>
</Style>

** Field definition:
<igDP:Field Name="Info"  Label="INFO">
                  <igDP:Field.Settings>
                  <igDP:FieldSettings CellValuePresenterStyle="{StaticResource labelStyle}"/>
         </igDP:Field.Settings>
</igDP:Field>