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

WPF grid throws exception when CollectionChanged fires on ItemsSource

2 Answers 183 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 06 Jun 2008, 12:17 PM
Hi,

We are just experimenting with the RadGridView in the WPF controls and have found that when we bind to an observable collection, CollectionChanged events cause the grid to throw an exception:

"This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread."
   
   at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at Telerik.Windows.Controls.Core.Data.VirtualizingRecordCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Controls.Core.Data.VirtualizingRecordCollection.Reset()
   at Telerik.Windows.Controls.Core.Data.VirtualizingRecordCollection.set_RealRecords(IList`1 value)
   at Telerik.Windows.Controls.Core.Data.RecordManager.RecalculateGroups()
   at Telerik.Windows.Controls.Core.Data.RecordManager.ResetRecords()
   at Telerik.Windows.Controls.Core.Data.RecordManager.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Controls.Core.Data.RecordManager.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)

This looks to be a bug in the grid as we haven't experienced this with the other WPF grids we tried. Do you know of a work around?

Many thanks,

Will Holley

2 Answers, 1 is accepted

Sort by
0
Will
Top achievements
Rank 1
answered on 09 Jun 2008, 01:36 PM
Just an update to this - we have solved it for now by proxying our source collection through a class which forwards all CollectionChanged events to the Dispatcher thread - doesn't seem ideal but it works.

see How to propagate changes across threads in WPF? for an example of something similar.
0
Nedyalko Nikolov
Telerik team
answered on 10 Jun 2008, 10:25 AM
Hi Will,
Thanks for the feedback. I think the problem is related to propagating changes across threads.
Such problems are very well explained in the following blog post: http://www.beacosta.com/blog/?m=200609

I modified a little the Beatriz Costa's example and just changed the ListBox control with Telerik RadGridView for WPF and all seems to work fine. See attachment for the modified example.

Should you have any additional questions/problems don't hesitate to contact us.

Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Will
Top achievements
Rank 1
Answers by
Will
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or