是否有列表在 .NET 2 中,列表更改时会引发事件吗?
我过去曾使用过 ObservableCollection
如果没有,那么合适的接口是什么? INotifyPropertyChanged
似乎不太适合集合,而 INotifyCollectionChanged
同样仅在 .NET 3 及更高版本中受支持。
I have used ObservableCollection<T>
in the past, but that seems to belong to WPF and therefore .NET 3.
And if there isn't what would be the appropriate interface for that? INotifyPropertyChanged
seems not to be a very good fit for collections, while INotifyCollectionChanged
is again only supported in .NET 3 and higher.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
BindingList
BindingList<T>
Collection 公开虚拟 InsertItem、RemoveItem、SetItem 和 ClearItems您可以覆盖并添加您自己的事件触发器的方法。
(只是 BindingList的可能替代方案)
The Collection<T> exposes virtual InsertItem, RemoveItem, SetItem and ClearItems methods that you could override and add your own events triggers to.
(Just a possible alternative to the BindingList<T>)
C5 通用集合库中的所有集合均设计为能够在以下情况下引发事件:添加、插入、删除项目,或者清除或以其他方式更改集合时。它提供了一个比严格保留对象列表更强大的接口来处理这些更改,而且还可以与字典、哈希表、优先级队列、持久排序列表等一起使用。
All of the collections in the C5 Generic Collection Library are designed to be able to raise events when an item is added, inserted, removed, or when the collection is cleared or otherwise changed. It provides a more robust interface for dealing with these changes than being held strictly to a list of objects, but also works with dictionaries, hash tables, priority queues, persistently sorted lists, etc.