Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello ,
I am having a data grid which has a checkbox column and is binded to a property "Used". The foreground color is binded to this property.

his works fine when I do not add any more condition

                    <Style TargetType="{x:Type toolkit:DataGridRow}">
                            <DataTrigger Binding="{Binding Used}" Value="True">
                                <Setter Property="Foreground" Value="Green"/>
                                <Setter Property="Background" Value="LightSlateGray"/>
                                <Setter Property="ToolTip"    Value="This Observation is Selected."/>
                            <DataTrigger Binding="{Binding Used}" Value="False">
                                <Setter Property="Foreground" Value="Red"/>
                                <Setter Property="Background" Value="Black"/>
                                <Setter Property="ToolTip"    Value="This Observation is Observed."/>

This grid is being populated and Used is a checkbox Column in this grid.
This works fine , based on cetain condition some rows become red and some green.
i.e if i>10 then Used = true
else Used = false

Now with this existing set , if the user decides that though i==8, still he would like that row to change the background color but this time to orange to indicate that this was manually forced.

How do I change the color of the row based on this .

Can somebody please help.

Updated 8-Jan-10 12:31pm

Since you want to have three or more states, you have to have a variable that can show three or more states that is an integer. Expand your binding value accordingly and then you can select the color set that is appropriate for each case.

You are likely to have to expand this further when it occurs to you that even more visual states need to be accomodated.

In the future, design for possible expansion needs and not just for the moment. Remember the major cost of software is not in the initial design, but in the maintanence.
Share this answer
f i>10 then Used = true
else Used = false

which is VB not C#


if i>10 orelse userChoseRed=True then Used = true
else Used = false

EDIT: Actually, that's pseudo code, not VB.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900