If I create a new ObservableCollection<T>, and a CollectionChanged listener as follows:
var c = new ObservableCollection<MyType>();
c.CollectionChanged += new NotifyCollectionChangedEventHandler(h);
...
void h(object sender, NotifyCollectionChangedEventArgs e)
{
IList newItems = e.NewItems;
// non generic IList! :(
}
Why isn’t e.NewItems an IList<MyType>?
The
ObservableCollectionis designed to support databinding scenarios in platforms like WPF where the databound controls don’t care about the type of the collection they’re bound to. Making the notifications generic would only make it much harder to write the controls without giving any benefit.