6

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

Louis Rhys
  • 34,517
  • 56
  • 153
  • 221

1 Answers1

8

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)
CodeNaked
  • 40,753
  • 6
  • 122
  • 148