如果我创建一个新的ObservableCollection<T>和一个CollectionChanged监听器,如下所示:
var c = new ObservableCollection<MyType>();
c.CollectionChanged += new NotifyCollectionChangedEventHandler(h);
...
void h(object sender, NotifyCollectionChangedEventArgs e)
{
IList newItems = e.NewItems;
// non generic IList! :(
}为什么e.NewItems不是IList<MyType>
发布于 2011-11-03 23:22:22
ObservableCollection旨在支持像WPF这样的平台中的数据绑定方案,其中数据绑定控件并不关心它们绑定到的集合的类型。让通知泛化只会让编写控件变得更加困难,而不会带来任何好处。
发布于 2011-11-03 23:21:55
可能是因为它可以用于非泛型集合以及ObservableCollection<T>
https://stackoverflow.com/questions/7997381
复制相似问题