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 开发者_Go百科I missing another .NET collection that already has this type of behavior?
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.
Just use System.ComponentModel.BindingList<T>
instead. The ListChanged
event it has will fire when any item in the list fires it's INotifyPropertyChanged
.
精彩评论