This is a migrated thread and some comments may be shown as answers.

Changing the row background through bindings

2 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose Simas
Top achievements
Rank 2
Jose Simas asked on 21 Sep 2010, 06:56 PM
Hi,

In my GridView I need to change the background of certain rows depending on one property of the object bound to that row. I found the forum thread below which explains how to do it but as soon as I change the references on the examples posted to the latest version of the GridView it does not compile. Would you please update the example or point me to another solution?

http://www.telerik.com/community/forums/wpf/gridview/how-can-i-apply-different-colors-to-radgridview-rows-through-bindings.aspx

Best Regards,
Jose Simas

2 Answers, 1 is accepted

Sort by
0
Jose Simas
Top achievements
Rank 2
answered on 22 Sep 2010, 09:49 AM
This is actually quite easy to do but I lost a couple of hours looking for the solution so I thought I would post here the answer.

<telerik:RadGridView ItemsSource="{Binding}" AutoGenerateColumns="True" Name="radGridView1">
    <telerik:RadGridView.RowStyle>
        <Style TargetType="{x:Type GridView:GridViewRow}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding MyFlag}" Value="True">
                    <Setter Property="Background" Value="LightBlue"/>
                    <Setter Property="Foreground" Value="Black"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </telerik:RadGridView.RowStyle>
</telerik:RadGridView>
0
Vanya Pavlova
Telerik team
answered on 22 Sep 2010, 02:02 PM
Hello Jose Simas,

You can also use Conditional Styles and Templates for RadGridView-WPF/SL.
Other than that using DataTriggers is probably the most straightforward way to go.

All the best,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jose Simas
Top achievements
Rank 2
Answers by
Jose Simas
Top achievements
Rank 2
Vanya Pavlova
Telerik team
Share this question
or