Change Row Background color based on condition

4 posts, 0 answers
  1. farizvi
    farizvi avatar
    8 posts
    Member since:
    Feb 2007

    Posted 25 Feb Link to this post

    I've been trying to change the row background color in radgridview based on a condition in RowLoaded event handler

    [code]
    if(myCondition)
    {
        var row = e.Row;
        Style style = new Style(typeof(GridViewRow));
        style.BasedOn = e.Row.Style;
         style.Setters.Add(new Setter(GridViewRow.BackgroundProperty, new SolidColorBrush(Colors.Orange)));
         style.Setters.Add(new Setter(GridViewRow.ForegroundProperty, new SolidColorBrush(Colors.Green)));

    }
    [/code]
    The Foreground color is set correctly but nothing happens to the Background color. Am I missing something?
  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 25 Feb Link to this post

    Hello,

    Please refer to your other forum thread on the same question - Change Row Background color based on condition .

    Regards,
    Yoan
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. farizvi
    farizvi avatar
    8 posts
    Member since:
    Feb 2007

    Posted 25 Feb in reply to Yoan Link to this post

    Hi!

    Thanks for your response. Isn't it possible without overriding SelectStyle?

  5. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 25 Feb Link to this post

    Hi,

    Generally, it is not recommended to work with the visual elements directly. This is why I had suggested the use of StyleSelector. Please check the Styling or content mixed-up on scrolling help article for a reference.

    Regards,
    Yoan
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top