How can an ObservableCollection fire a Replace action?
Asked Answered
F

1

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

Flagstone answered 1/7, 2011 at 2:59 Comment(0)
M
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)
Marty answered 1/7, 2011 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.