I want to update the collection after changing it, but I cannot "get away" from this exception:
Cannot change ObservableCollection during CollectionChanged or PropertyChanged event.
Inside the event handler, I unsubscribe from the Collection event changed before changing anything to prevent endless loops, and after making the changes, I subscribe to the same event again.
private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
data.CollectionChanged -= CollectionChanged;
data.Add("Item");
data.CollectionChanged += CollectionChanged;
}
I tried using Dispatcher to call data.Add ("Item"), but no luck :(
source
share