So I have a control that has a generic list List. In normal non compiled Xaml I simply use something like:
<controls:CustomControl>
<controls:CustomControl.FooList>
<FooBar />
<FooBar />
<FooBar />
</controls:CustomControl.FooList>
</controls:CustomControl>
This works out fine because in the constructor of the cs file I put:
public CustomControl( )
{
if( FooList == null )
FooList = new List<FooBar>( );
}
Now you cannot put it in the default of the dependency property because all controls instantiated will use the exact same list(in memory) so I do it in the constructor. Although when using XamlC I get error : Sequence contains no elements because it thinks I am putting in multiple objects into one field instead of a list. Is this expected? If I make a custom list FooBarList : List then it works fine and I have to put two extra lines of code into each xaml file to get around it.
EDIT: This is what works for Xaml using XamlC:
<controls:CustomControl>
<controls:CustomControl.FooList>
<controls:FooBarList>
<FooBar />
<FooBar />
<FooBar />
</controls:FooBarList>
</controls:CustomControl.FooList>
</controls:CustomControl>
It also sucks having to make custom lists for all my controls that use multiple children, maybe there is a better way?