Add value changes to NotifyCollectionChangedEventArgs?

Apr 14, 2011 at 7:02 PM

In the full framework a copy of the new value(s) and/or old value(s) are provided in the Event Args. This could mean a big hit to our memory but having some sort of copy of what's changed would be good. Providing an index to the item might be sufficient but this could quickly become stale if there are other insert or remove operations.

Is it better to just have a copy of the element that changed/added/removed instead of the entire array at the time of the change? This would use an acceptable amount of memory and would provide a predictably correct value.

Right now Add and Insert events are treated the same. An Add action would get only a NewValue. What would Insert do? No value changed, just the positions shifted. Should this too just be a NewValue? Remove would be OldValue? In this case there would be no need for both a New- and OldValue but just Value parameter and the ActionType would be what specifies if it's an add or remove?

Additionally, there is no event raised if an item is changed. This would be handled by INotifyPropertyChanged but that's not implemented nor do I think I will implement it. Should I just add it as another ActionType to the CollectionChanged event? I could see wanting to know a value changed in addition to adds/removes. This seems easiest with the smallest footprint for increased functionality but is a bit of a departure from the full framework. Is this a problem?


Feedback greatly appreciated.