Hello,
After reading multiple questions in this forum regarding why the RadGridView is not refreshing when an existing item is updated, I am developing the refresh mechanism. I tried your suggest (calling CollectionChanged.Reset) but this solution is not good for us because when we call CollectionChanged the RadGridView is updated and also a lot of elements are drawn in a screen (thousand of elements and it cost a lot of performance).
So my solution is using a timer with refresh interval of 1 second which will refresh all the subscribed RadGridViews.
* I used WeakRefereces to avoid Memory Leaks.
In the distpatcher timer I do the following code:
if(radGridView == null || !radGridView.IsVisible) return;
var isRefreshRequired = radGridView.GroupDescriptors.Count >0 || radGridView.FilterDescriptors.Count>0 || radGridView.SortDescriptors.Count>0
if(isRefreshRequired)
{
var collectionView = CollectionViewSource.GetDefaultView(radGridView.ItemSource);
collectionView.Refresh?();
}
As mentioned, this code guarantees that only the view (RadGridView) is refresh and not the other elements of the SourceCollection.
I need your help with the following:
1. Only when there is a group and I scrolled down, after refresh the grid jumps to top (I couldn't reproduce when sorting or filter is enabled).
2. There is any good way to really know if the RadGridView is shown on screen (maybe it is visible but hidden in other tab), I need a method with fast access because I may check around 15 grids every second and I want to refresh only the required grids.
3. I tried to refresh the radGridView.Items instead of radGridViewItemsSource.
I expected this to work beause Items holds the items after grouping/filter/sorting. Unfortuneatly ,it doesn't work.
There is any way to refresh your internal view instead of the SourceCollection view that is bound to ItemSource?
The problem is that CollectionChanged on the view, triggers other code on my side that it will be good to skip for this case.
EDIT:
* I figured out that if I have a grid with 500 elements with two groups of 250 rows and one group is expanded then the application is almost freeze, the refresh is killing the performance. I think that my solution is better than Collection Reset so I don't know how to solve this :(
* Regarding point one, I think that the grid jumps because the Panel Unit is set to Content. I can't switch to Pixel because it will cause bad performance.
* I noticed that you have the method Reset for GroupDescriptors and SortDescriptors, the performance is the same. I taught that you maybe manage an internal caching and have some improvements there.