Which NotifyCollectionChangedAction is used to indicate that an item changed?
-
23-10-2019 - |
Question
When implementing INotifyCollectionChanged
and raising the CollectionChanged
event, you must provide a NotifyCollectionChangedAction
argument. Which NotifyCollectionChangedAction
is used to indicate that an item in the collection has changed, such as in the case where an item's value changes?
Solution
If it's the same object, but a field changes (e.g. same Person, but different Person.Photo), the collection didn't change. Otherwise, every change to the collection is one of the Enum values.
If one Person is replaced by another, that's a Replace.
OTHER TIPS
If a property of an item has changed, but the item (i.e. the object) has remained the same, you should use INotifyPropertyChanged on the item.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow