UIElementCollection 和 Collection之间的区别?

发布于 2024-11-28 11:05:03 字数 937 浏览 1 评论 0原文

在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...

所有这些类都派生自一个公共类一样,并且我在派生类(它们都是空的!),那么他们为什么首先定义它们呢?我觉得派生类中声明的 privateinternal 存在一些差异。但我不太清楚。

请帮助我理解这些课程的设计。特别是,为什么他们使用它们而不是框架附带的通用类?有什么好处?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒解孤独 2024-12-05 11:05:03

根据其设计用途,它们的内部工作方式有所不同。例如,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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文