Coloring grid rows based on data values

3 posts, 0 answers
  1. David
    David avatar
    7 posts
    Member since:
    Oct 2010

    Posted 01 Oct 2010 Link to this post


    I tried using this approach that I found in the WPF forums:

    However, this isn't working for me in Silverlight. I get the following error:
    "XamlParseException occurred."
    Set property '' threw an exception. [Line: 41 Position: 69]

    Here is my Xaml:




    <telerik:RadGridView x:Name ="itemGrid" IsReadOnly="False"








    ItemsSource="{Binding AdTypes, Mode=TwoWay}"




    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"






















    <Style TargetType="telerik:GridViewRow">





    <Setter Property="Background" Value="{Binding Active, Converter={StaticResource ActiveConverter} }"></Setter>












  2. Milan
    Milan avatar
    1989 posts

    Posted 07 Oct 2010 Link to this post

    Hi David,

    Unfortunately Silverlight does not support binding such binding in style setters but you can apply the same binding in code-behind using our RowLoaded event. For example:

    public MainWindow()
        this.DataContext = (from c in Enumerable.Range(0, 10)
                            select new Order
                                Due_Date = DateTime.Now.AddDays(c),
                                ID = c,
                                Name = "Name" + c
        this.gridView.RowLoaded += new EventHandler<RowLoadedEventArgs>(gridView_RowLoaded);
    void gridView_RowLoaded(object sender, RowLoadedEventArgs e)
        var row = e.Row as GridViewRow;
        if (row != null)
            Binding b = new Binding("Due_Date");
            b.Source = e.Row.Item;
            b.Converter = new DateToColorConveter();
            row.SetBinding(GridViewRow.BackgroundProperty, b);

    All the best,
    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
  3. DevCraft R3 2016 release webinar banner
  4. Joseph Gershgorin
    Joseph Gershgorin avatar
    28 posts
    Member since:
    Aug 2009
Back to Top