I am using XamGrid which is bounded to collectionviewsource, apparently when i add filter row to the xamgrid (via below xaml) i get the exception "cannot change observablecollection during a collectionchanged event" i.e. when the first row is added to the collection, it seems the gridmanager is initializing the rowfilter when the first row is added.
Appreciate if you could shed some light why i might be getting this exception or how i can avoid it?
I am using the latest service release
<ig:XamGrid x:Name="grid" Grid.Row="1"> <ig:XamGrid.FilteringSettings> <ig:FilteringSettings AllowFiltering="FilterRowTop" FilteringScope="ColumnLayout"> </ig:FilteringSettings> </ig:XamGrid.FilteringSettings> </ig:XamGrid>
at System.Collections.ObjectModel.ObservableCollection`1.CheckReentrancy() at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value) at System.Windows.Data.ListCollectionView.AddNewCommon(Object newItem) at Infragistics.DataManagerBase.GenerateNewObject() at Infragistics.Controls.Grids.RowsManager.GenerateNewObject(RowType rowType) at Infragistics.Controls.Grids.RowsManager.ResetFilterRows(Boolean generateNewData) at Infragistics.Controls.Grids.RowsManager.InitializeData() at Infragistics.Controls.Grids.RowsManager.ItemsSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex) at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at ... <I add value to the underlying collection here>
HI,
I could not reproduce this issue with build 13.1.2073.
I am attaching my sample.
Please test on your machine and feel free to modify the sample and provide the steps to reproduce.
Sincerely,
Matt
Developer Support Engineer
I created a standalone application as well as used your program but somehow I could not manage to reproduce it either (I am using service release 12.2.20122.2204). I then decompiled the xamgrid dll/pdb and can see that when i first add a row to the underlying data collection, it triggers observablecollectionchanged notification, upon which the infragistics grid manager resets the rows and row filter, it then adds a new filter row to the rows collection, since we are adding row filter on an observablecollection changed it throws the exception "cannot change observable colelction during collection changed event". I think it might be worth running this issue with your development team or create a case if you could shed more light why it could happen in some cases but not all.
The way i fixed this issue is by removing filteringsettings attribute from the xaml view and add the filteringsettings on the code behind (i hate View Aware view models).
Thanks,
Rohit
This issue has been address by the latest service release.
To download the service release:
1. Visit the My Keys & Downloads page.
2. Select the NetAdvantage Product/Key that you wish to download the service release for.
3. Select the Service Releases tab.
4. Select the appropriate service release download.
Please let me know if you need further assistance.
HI ,
I replicated your issue and have notified the developers.
I have created a private case for this issue and will email you shortly.
OK,
I can reproduce the issue at will, please see the two files attached. If you will remove the commented out line in .xaml.cs (i.e. "listBox.ItemsSource setter" you can see it will work ok) but not with infragistics xamgrid.
To reproduce click on "Apply layout" first and then "Add Items", clicking on add items you should see the exception
Next remove FilteringSettings xaml, try again and it will work again ok
<ig:XamGrid.FilteringSettings> <ig:FilteringSettings AllowFiltering="FilterRowTop" FilteringScope="ColumnLayout"> </ig:FilteringSettings> </ig:XamGrid.FilteringSettings>