Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional text-color for the DataGrid rows?

Tags:

wpf

row

datagrid

I have a datagrid which is bound to a database table. I need to change the forecolor of a row to blue depending on there is a value in one of its columns. Is there a way I can do this? I tried IValueConverter, but I presume I can use this only for one cell at a time.

like image 886
sony Avatar asked Nov 24 '11 15:11

sony


1 Answers

<DataGrid>
    <DataGrid.CellStyle>
        <Style TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding SomeProperty}" Value="SomeValue" >
                    <Setter Property="Foreground" Value="Blue" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </DataGrid.CellStyle>
</DataGrid>
like image 196
kevev22 Avatar answered Oct 15 '22 04:10

kevev22