Listen to the PropertyChanged event of any item in an ObservableCollection<INotifyPropertyChanged>

0 votes
asked Aug 16, 2010 by chilltemp

I've created a wrapper collection for ObservableCollection that subscribes to each items PropertyChanged event and rethrows it as its own event ItemPropertyChanged. I did this using a similar method to what I described here. Is there a better way? Am I missing another .NET collection that already has this type of behavior?

2 Answers

0 votes
answered Aug 6, 2011 by scptre

There was already a post about this on stackoverflow. It also provides a quick implementation of a new collection type that exposes an event to get this to work.

See Link: ObservableCollection that also monitors changes on the elements in collection

0 votes
answered Aug 13, 2012 by michael-l-perry

I'm assuming that you are firing this event in order to compute an aggregate. I have a different solution to this problem. Consider using Update Controls with linq. You can declaratively describe your aggregate with linq, and Update Controls will track its dependencies within your collection. Whenever the collection changes, or any of the referenced properties changes, then it will reevaluate the aggregate.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter