Difference between UIElementCollection and Collection<UIElement>?
In WPF and Silverlight, we have seen the following classes:
UIElementCollection
ItemCollection
RowDefinitionCollectio开发者_运维问答n
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?
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...
精彩评论