You have several options:
- Add INotifyPropertyChanged so that you can tell the user interface that the value of the elements has changed. This does not use the fact that INotifyCollectionChanged is implemented on an ObservableCollection. It will work, but it defeats the goal of using an ObservableCollection in the first place. This is not recommended, but it works.
- Use the methods ObservableCollection Add / Remove / Modify / Update to change it together with the Dispatcher.
- Note: without a dispatcher, you will get a NotSupportedException because CollectionViews do not support changes to the SourceCollection from a stream other than the Dispatcher stream.
- Use the ObservableCollection Add / Remove / Modify / Update methods to modify it in conjunction with
BindingOperations.EnableCollectionSynchronization . Recommended- Note. This is available only in .NET 4.5.
- This is an alternative to using the dispatcher, avoiding the NotSupportedException.
- Example
The numbers 2 and 3 in relation to your question, translate to cleaning the existing elements (Clear ()), and then add (Add ()) the elements returned in whatever way you want - see example for # 3. They indicate that cleaning and all additions must be done with the Manager (2) or by calling BindingOperations.EnableCollectionSynchronization . Good luck
Link: fooobar.com/questions/950832 / ...
source share