WPF RadGridView Change Row Color Based on checkbox event

2 posts, 0 answers
  1. sangram
    sangram avatar
    3 posts
    Member since:
    Mar 2016

    Posted 02 Feb 2017 Link to this post


    I need help for changing WPF RadGridView Row Color Based on checkbox event.

    Since Radgrdiview has more than 1000 records most of the record are invisible,

    so due to virtualization below code is not working , row color changes when user scroll grdiview

       this.userGridView.CurrentCell.ParentRow.Background = Brushes.Red;


    RadGridView of the screen is created dynamically and in the grid one of column is containing checkboxes.

    Based on requirements row color of checkboxes which are checked are green and unchecked check box row color are grayed.

    If one of the unchecked check box is marked as check from user its row should change to "Red" and if again unchecked it should be "Dark Gray".

    I need help to code dynamically from xaml.cs


    Please find below code snippet which I have tried.

     this.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(CheckBoxChecked));
      private void CheckBoxChecked(object sender, RoutedEventArgs e)
                if (userGridView.CurrentCell != null)

  2. Dilyan Traykov
    Dilyan Traykov avatar
    1099 posts

    Posted 07 Feb 2017 Link to this post


    As suggested in the UI virtualization article, you should not work with the visual elements of the control (GridViewCell, GridViewRow, etc.) directly as this will result in inconsistent behavior due to the containers' recycling mechanism. Instead, you should use the underlying data items as explained in the Style Selectors section.

    In this case, you can introduce a new property of your business objects (IsSetByUser for example) and use this in your style selector's SelectStyle method.

    Do let me know whether I can further assist you in any way.

    Dilyan Traykov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top