问题描述
为<$ C $的MSDN参考页C>的ObservableCollection&LT; T&GT; 注意事项:
The MSDN reference page for ObservableCollection<T>
notes:
https://msdn.microsoft.com/en-us/library/ms743643(v=vs.100).aspx相对=在您的收藏必须满足在的。特别是,如果你使用的或的(例如,你希望你的UI更新,当源属性动态改变),则必须实现一个合适的属性更改通知机制,如 INotifyPropertyChanged的的接口。
由于的ObservableCollection&LT; T&GT;
已经实现了 INotifyPropertyChanged的
,为什么我需要再次实施 INotifyPropertyChanged的
在 T
也?
Since ObservableCollection<T>
already implements INotifyPropertyChanged
, why do I need to again implement INotifyPropertyChanged
on T
also?
推荐答案
考虑您观察到的集合作为数据源的表。从收集的每个对象占用一行,并显示在跨多个列的表
Consider your observable collection as a data source for a table. Each object from the collection occupies one row, and is displayed in the table across multiple columns.
的视图(即你表)需要知道何时修改每个细胞响应于改变对象的属性,而且还响应于添加和删除对象和从集合
The view (i.e. your table) needs to know when to modify each cell in response to changing properties of objects, but also in response to adding and removing objects to and from the collection.
您观察到的领取应付照顾的表行的:它会通知它的观察者,当一个对象被插入,删除,移动等。但是,它缺乏一个什么样的个别对象回事知识,所以它是没有帮助在处理的表中的列的。
Your observable collection takes care of dealing with table rows: it notifies its observers when an object gets inserted, removed, moved, and so on. However, it lacks knowledge of what's going on with individual objects, so it is of no help in dealing with table columns.
这是你的对象有:通过实施 INotifyPropertyChanged的
,他们让你的表管理中的列中的数据。
This is where your objects come in: by implementing INotifyPropertyChanged
they let your table manage the data in the columns.
这篇关于当使用的ObservableCollection&LT; T&GT ;,我还需要实现INotifyPropertyChanged的T类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!