In the documentation of the event args of NotifyCollectionChangedEventArgs, there is an action called Replace (in addition to Add, Remove, Move, etc.). When can this be fired? I can't see any Replace method in ObservableCollection
An ObservableCollection is a dynamic collection of objects of a given type. Objects can be added, removed or be updated with an automatic notification of actions. When an object is added to or removed from an observable collection, the UI is automatically updated.
WPF and Silverlight have a special generic collection class ObservableCollection which provides notification about updating such as when items get added, removed, or when the entire list is refreshed.
Here is an example:
ObservableCollection<string> myCollection = new ObservableCollection<string>;
myCollection.Add("One");
myCollection.Add("Two");
myCollection.Add("Three");
myCollection.Add("Four");
myCollection.Add("Five");
myCollection[4] = "Six"; // Replace (i.e. Set)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With