This is a not an issue with RadGridView per say, but somewhat related. Hopefully someone can suggest an alternative solutions for me.
I have a simple RadGridView which is binded to a BindingList with about 2,500 items. The item that is in BindingList inherits ObservableObject from MVVMLight, hence implements INotifyPropertyChanged interface. One of my properties is boolean called "Selected" which is binded to a checkbox column. I have a button "Select All". On click, I need to mark all items as selected. On the backend, I do a simple foreach loop and set Selected = True. Here is the code.
foreach (var p in Products)
p.Selected = true;
Very simple. But this loop takes almost 10 minutes. I figured out that the issue is related to the BindingList. I did some isolated Tests (without UI). Simply created a model that implements INotifyPropertyChanged interface, created 1000, 2000, and 3000 records and evaluated the performance. The result came out to be the longer the list, the more time per item it takes to set simply selected=true. Here are results
1000 items => 11 sec total => 0.011 sec/cycle
2000 items => 44 sec total => 0.022 sec/cycle
3000 items => 100 sec total => 0.033 sec/cycle
as you can see the average per cycle increases when there are more items in the BindingList
I did some research and this article explains why this is happening: http://www.blog.dapfor.com/why-bindinglist-is-slow-with-objects-implementing-inotifypropertychanged-interface
I tried using approach from the article above. My loop works in milliseconds. Great! But now, my checkbox column in the grid does not get updated until I select each row and loose focus. Obviously the grid does not get a notification to update its cells.
I also tried setting RaiseListChangedEvents = false before the loop and then list.RaiseListChangedEvents = true after the loop. Result is the same.
So my question is
1. Is there an alternative class that implements IBindingList interface which would yield a linear increase in time as more items are added, not exponential?
2. If there is no other way, then I guess my only option is to refresh the grid after I update the binding list. How do I do this?
3. Any other suggestions?
Thank you in advance.