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

WPF RadGridView Change Row Color Based on checkbox event

1 Answer 190 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sangram
Top achievements
Rank 1
sangram asked on 02 Feb 2017, 03:35 PM

Hello,

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)
            {
              ?????????????
            }
        }

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 07 Feb 2017, 01:19 PM
Hello,

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.

Regards,
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 you to write beautiful native mobile apps using a single shared C# codebase.
Tags
General Discussions
Asked by
sangram
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or