UIElementCollection 和 Collection之间的区别?
在WPF和Silverlight中,我们看到了以下类:
UIElementCollection
ItemCollection
RowDefinitionCollection
ColumnDefinitionCollection
PointCollection
code>- 等等......
为什么他们有这些类,每种类型一个类?他们为什么不使用诸如Collection
之类的泛型类?
另外,我在 Silverlight 中看到,所有这些类都派生自 PresentationFrameworkCollection
,就好像
public sealed class ItemCollection : PresentationFrameworkCollection<Object>
public sealed class PointCollection : PresentationFrameworkCollection<Object>
public sealed class IconCollection : PresentationFrameworkCollection<Object>
//and so on...
所有这些类都派生自一个公共类一样,并且我在派生类(它们都是空的!),那么他们为什么首先定义它们呢?我觉得派生类中声明的 private
或 internal
存在一些差异。但我不太清楚。
请帮助我理解这些课程的设计。特别是,为什么他们使用它们而不是框架附带的通用类?有什么好处?
In WPF and Silverlight, we have seen the following classes:
UIElementCollection
ItemCollection
RowDefinitionCollection
ColumnDefinitionCollection
PointCollection
- and a lot more....
Why do they have these classes, one class for each type? Why did they not use generic classes such as Collection<T>
?
Also, I've seen in Silverlight, all of these classes have been derived from PresentationFrameworkCollection<T>
, as
public sealed class ItemCollection : PresentationFrameworkCollection<Object>
public sealed class PointCollection : PresentationFrameworkCollection<Object>
public sealed class IconCollection : PresentationFrameworkCollection<Object>
//and so on...
If all of these derive from a common class, and I don't see anything public in the derived classes (all of them are empty!), then why did they define them in the first place? I feel that there are some differences which are either declared private
or internal
in the derived classes. But I don't exactly know.
Please help me understanding the design of these classes. In particular, why did they use them instead of generic classes which come with the framework? What are the benefits?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据其设计用途,它们的内部工作方式有所不同。例如,
UIElementCollection
不仅保存元素,还确保它们在相应的可视化树中添加和删除......They internally work different, based on the use case they were designed for. For example,
UIElementCollection
doesn't just hold the elements, but also makes sure they are added and removed from the corresponding visual tree...