I have an ObservableCollection<CustomClass>. The CustomClass has a few properties. One of them is called Name and of type string. The whole thing is bound to a WPF datagrid. Now I need to get notified when the Name of any member of the collection is changed. The CollectionChanged event of the collection is not fired. I could implement INotifyPropertyChanged but where do I listen to it?
I have an ObservableCollection<CustomClass> . The CustomClass has a few properties. One of them
Share
Initial answer
You indeed need to implement INotifyPropertyChanged on your custom class, and you need to subscribe to the PropertyChanged event of ALL objects in the collection. If a property is updated, you’ll get notified of the change of that single object.
Update
If you want to see what the old and the new values are, then you need to create your own PropertyChanged event (maybe name it PropertyUpdated to prevent confusion which is which).
Something like below. If you implement this event (like the custom class shows), and use this event instead of INotifyPropertyChanged, then you have access to the old and new value of the updated property in the event arguments when you’re handling the event.