Hello!
We have recently tried in our company to switch XamDataGrid in one of our products to grouping, sorting and filtering using CollectionView like that:
<igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings ... SortEvaluationMode="UseCollectionView" GroupByEvaluationMode="UseCollectionView" FilterEvaluationMode="UseCollectionView" SummaryEvaluationMode="UseLinq" /></igDP:XamDataGrid.FieldLayoutSettings>
Every 3 seconds 5000 records is added to the collection that is a datasource for the grid. The records are added in the UI thread. Some records contain child records. If, during the time of that recurring record addition, I try to do something in the grid, for example, expand some group or scroll through the displayed records, I get IndexOutOfRange exception in the ValidateIndex method of InfragisticsWPF4.v16.1.dll.
Here is the full stack trace:
------
InfragisticsWPF4.v16.1.dll!Infragistics.Collections.SparseArray.ValidateIndex(int index = 19893) Line 2297 C# InfragisticsWPF4.v16.1.dll!Infragistics.Collections.SparseArray.SetItemHelper(int index = 19893, object item = {Infragistics.Windows.DataPresenter.DataRecord}, bool performingAdd = false) Line 2195 C# InfragisticsWPF4.v16.1.dll!Infragistics.Collections.SparseArray.this[int].set(int index = 19893, object value = {Infragistics.Windows.DataPresenter.DataRecord}) Line 2317 C# InfragisticsWPF4.DataPresenter.v16.1.dll!Infragistics.Windows.DataPresenter.DataRecordsSynchronizer.Process_CollectionChangedWhenAsyncResetPending(object sender = Count = 19894, System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) Line 121 C# InfragisticsWPF4.DataPresenter.v16.1.dll!Infragistics.Windows.DataPresenter.ListSynchronizer<object,Infragistics.Windows.DataPresenter.DataRecord>.OnSource_CollectionChanged(object sender = Count = 19894, System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) Line 232 C#> System.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown System.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.HandleCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown System.dll!System.Collections.ObjectModel.ObservableCollection<object>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Unknown System.dll!System.Collections.ObjectModel.ObservableCollection<System.__Canon>.InsertItem(int index, System.__Canon item) Unknown mscorlib.dll!System.Collections.ObjectModel.Collection<object>.Add(object item) Unknown PresentationFramework.dll!MS.Internal.Data.CollectionViewGroupInternal.Add(object item) Unknown PresentationFramework.dll!MS.Internal.Data.CollectionViewGroupRoot.AddToSubgroups(object item, MS.Internal.Data.LiveShapingItem lsi, MS.Internal.Data.CollectionViewGroupInternal group, int level, bool loading) Unknown PresentationFramework.dll!MS.Internal.Data.CollectionViewGroupRoot.AddToSubgroup(object item, MS.Internal.Data.LiveShapingItem lsi, MS.Internal.Data.CollectionViewGroupInternal group, int level, object name, bool loading) Unknown PresentationFramework.dll!MS.Internal.Data.CollectionViewGroupRoot.AddToSubgroups(object item, MS.Internal.Data.LiveShapingItem lsi, MS.Internal.Data.CollectionViewGroupInternal group, int level, bool loading) Unknown PresentationFramework.dll!System.Windows.Data.ListCollectionView.PrepareGroups() Unknown PresentationFramework.dll!System.Windows.Data.ListCollectionView.PrepareLocalArray() Unknown PresentationFramework.dll!System.Windows.Data.ListCollectionView.RefreshOverride() Unknown PresentationFramework.dll!System.Windows.Data.CollectionView.RefreshInternal() Unknown PresentationFramework.dll!System.Windows.Data.CollectionView.Refresh() Unknown ------
Moreover, grid's filters work very unstable. Sometimes, they stop working after several filtrations.
Any solution to that problem will be highly appreciated!
Hello Oleg,
Thank you for reaching out. I will be working on a sample to isolate this issue in order to resolve it. To help us resolve this quicker please send us an isolated sample project where this is reproduced so I can investigate it further for you. I'd greatly appreciate it.
Let me know if you have any additional questions regarding this matter.
Sincerely,
Michael Di FilippoAssociate Software DeveloperInfragistics, Inc.www.infragistics.com/support
Hi, Michael!
Thank you for the answer.
Here is the the isolated sample project where that problem is reproduced.
Steps to reproduce:
I've reproduced the exception. The reason for this behavior is because ObservableCollection does not support the AddRange method and not an issue with our toolset. I strongly recommend reading the following blog at MSDN which explains this more in depth.
https://blogs.msdn.microsoft.com/nathannesbit/2009/04/20/addrange-and-observablecollection/
I will be investigating a viable solution and will reply back by the end of the week.
Let me know if you have any questions regarding this matter.
Michael,
The behaviour will be the same if you change ObservableCollection to IList and make
(List)_items.AddRange(newItems)(ICollectionView)_itemsView.Refresh()
I've attached the sample application.
Oleg
Thanks, Michael.
Oleg,
I have created a private case for you with ID CAS-179662-B1R9J8. You could reach your case following the link bellow:
https://ko.infragistics.com/my-account/support-activity I will update again via the mentioned case, so if you have any further questions or comments please update your case accordingly.
I've managed to reproduce this behavior without having to rely on an Observerable implementation. The issue definitely stems from setting the FieldLayoutSettings property GroupByEvaluationMode to UseCollectionView. However you only need a single class that provides it's own PropertyChanged notifications to reproduce the behavior.
I'd like to add that it's only triggered when the vertical scrollbar appears. I made sure to only add one item every second to see what the minimal results were like. As soon as enough records extended beyond the grid's height the exception occured.
I will be creating a private case shortly to continue this converstation further. Let me know if you have any questions.
Thank you for following up. I am creating a smaller sample at the moment that reproduces this behavior to inspect this further. I'll follow up when I have more information regarding this issue.