Click here to Skip to main content
15,919,132 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

<toolkit:DataGrid.RowStyle>
                    <Style TargetType="{x:Type toolkit:DataGridRow}">
                        <Style.Triggers>
                            <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>
                            <DataTrigger Binding="{Binding Used}" Value="False">
                                <Setter Property="Foreground" Value="Red"/>
                                <Setter Property="Background" Value="Black"/>
                                <Setter Property="ToolTip"    Value="This Observation is Observed."/>
                            
                            </DataTrigger>
                        </Style.Triggers>


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.

Thanks
BV
Posted
Updated 8-Jan-10 12:31pm
v4

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
 
wrote:
f i>10 then Used = true
else Used = false


which is VB not C#

becomes

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

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

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