views:

1070

answers:

3

hey i wanna change row foreground color according to a boolean in the model, whats the best way of doing it?

+4  A: 

Define the style as following (IsBlah is a boolian property):

    <Style x:Key="MyRowStyle" TargetType="{x:Type dg:DataGridRow}">
        <Setter Property="Background" Value="White"/>
        <Setter Property="Foreground" Value="DarkBlue"/>      
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsBlah}" Value="False" >
                <Setter Property="Background" Value="DarkGray" />
                <Setter Property="Foreground" Value="White" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

Your DataGrid should have a custom RowStyle. (RowStyle="{StaticResource MyRowStyle})

Boris Lipschitz
A: 

Gr8t stuff been looking for code like this for a while

Garth
Just FYI - You should be leaving this type of feedback as a comment, not an answer.
Will Hughes
A: 

How would you go about styling individual cells instead of complete row styling

Garth
@Garth, no offense, but read what Will said to you on your previous post. Post this type of entries in comments. Posting again after being pointed seems either ignorance or arrogance. Both are not helpful here.
Yogesh