If you’ve ever consumed
INotifyCollectionChanged.CollectionChanged, then you’ve run into some inadequate documentation for
NotifyCollectionChangedEventArgs. I’ve added the following information to the MSDN “community extensions” (my first contribution), but others have had problems with the stability of community extensions, so the results of my research and Reflector spelunking are also in this blog entry.
In short, the value of the
Action property determines the validity of other properties in this class.
null when they are invalid;
-1 when they are invalid.
NewItems contains the items that were added. In addition, if
NewStartingIndex is not
-1, then it contains the index where the new items were added.
OldItems contains the items that were removed. In addition, if
OldStartingIndex is not
-1, then it contains the index where the old items were removed.
OldItems contains the replaced items and
NewItems contains the replacement items. In addition,
OldStartingIndex are equal, and if they are not
-1, then they contain the index where the items were replaced.
OldItems are logically equivalent (i.e., they are
SequenceEqual, even if they are different instances), and they contain the items that moved. In addition,
OldStartingIndex contains the index where the items were moved from, and
NewStartingIndex contains the index where the items were moved to. A
Move operation is logically treated as a
Remove followed by an
NewStartingIndex is interpreted as though the items had already been removed.
NotifyCollectionChangedAction.Reset, then no other properties are valid.
There are two blog entries that helped me get started: Making Sense of NotifyCollectionChangedEventArgs and An Alternative to ObservableCollection. However, more details were still lacking; fortunately, Reflector saved the day! The primary .NET sources were: [WindowsBase.dll, 126.96.36.199]
MoveItem, etc.; and [PresentationFramework.dll, 188.8.131.52]