Internal MailBag: Collection Types in XAML
Another mail that mail be useful to others outside our firewall…
By the way, MSDN has a section that goes into Collection Types and XAML Collection Properties
Btw, the reason List<T> works is because it implements IList.
IList, IDictionary or Array are the collection types we support.
List<T> or IList<T> is recommended as well, as it suggests the type of the children.
IList<T> isn’t supported by itself…partially due to dev time and partially due to perf concerns…if I recall correctly.
I’m designing a class that I want to be able to use in XAML. The class which has a collection-valued property called “Children”.
If I define “Children” as IList<T>, I get the following error: ‘Children’ is a read-only IEnumerable property, so ‘MyClass’ must implement IAddChild.
If I define “Children” as List<T>, things seem to work fine.
Can someone clarify what types XAML supports for collections? Why is IList<T> not acceptable? What is the recommended usage here?