Difference between UIElementCollection and Collection <UIElement>?

In WPF and Silverlight, we saw the following classes:

  • UIElementCollection
  • ItemCollection
  • RowDefinitionCollection
  • ColumnDefinitionCollection
  • PointCollection
  • and much more....

Why do they have these classes, one class for each type? Why didn't they use generic classes like Collection<T> ?

In addition, I saw in Silverlight all of these classes were 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 this comes from a common class, and I don’t see anything public in derived classes (they are all empty!), Then why did they define them in the first place? I feel that there are some differences that are either declared private or internal in derived classes. But I don’t know for sure.

Please help me understand the design of these classes. In particular, why did they use them instead of the general classes that come with the framework? What are the benefits?

+4
source share
1 answer

They work internally differently based on the use case for which they were designed. For example, UIElementCollection not only holds elements, but also provides their addition and removal from the corresponding tree of visual images ...

+6
source

All Articles