Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

Change datagrid cell color based on the value of the cell?

$
0
0
I've this DataGrid structure:

Code:

<DataGrid ItemsSource="{Binding MatchService.Matches}" AutoGenerateColumns="False"
                          CanUserAddRows="false" IsReadOnly="True">
        <DataGrid.Columns>
            <DataGridTextColumn Header="{DynamicResource championship}" Binding="{Binding Competition}"/>
            <DataGridTextColumn Header="1" Binding="{Binding HomeWin}"/>
            <DataGridTextColumn Header="X" Binding="{Binding Draw}"/>
        </DataGrid.Columns>

Essentially I need to change the background of all the cell that have 1 and X header, if the value of the row is: < 50 the cell should have a background of red, if is >60 green.

What I did until now is:

 <DataGrid.Resources>
        <Style TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="" Value="50">

                </Trigger>
            </Style.Triggers>
        </Style>

But I doesn't found any property that bind the generic value each DataGridTextColumn.

How can I achieve this?

Thanks.

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>