I'm struggling with DesignData in what should be a very simple case. I've defined the following trivial control in a Windows Universal Project
<UserControl
...
xmlns:local="clr-namespace:SimpleDataBind"
...
<UserControl.Resources>
<DataTemplate x:Key="SimpleListTemplate">
<TextBox Text="{Binding Name}" />
</DataTemplate>
</UserControl.Resources>
<Grid>
<StackPanel Grid.Row="0" d:DataContext="{d:DesignData Source=./DesignData/Single.xaml}">
<TextBox Text="{Binding Name}"/>
</StackPanel>
<ListView Grid.Row="1" d:DataContext="{d:DesignData Source=./DesignData/Multiple.xaml}"
ItemTemplate="{StaticResource SimpleListTemplate}"
ItemsSource="{Binding collection}">
</ListView>
</Grid>
The classes are defined as follows:
public class Element
{
public Element() { }
public string Name { get; set; }
}
public class ElementCollection : ObservableCollection<Element>
{
public ElementCollection() { }
}
An element 'collection' of type ElementCollection is defined in the codeBehind to give a valid Binding Source.
Single.xaml is trivial:
<local:Element xmlns:local="clr-namespace:SimpleDataBind" Name="Single" />
Multiple is equally so:
<local:ElementCollection xmlns:local="clr-namespace:SimpleDataBind" >
<local:Element Name="Multiple Pete" />
<local:Element Name="Multiple George" />
<local:Element Name="Multiple John" />
</local:ElementCollection>
When viewed in the Designer, we should see the design data above. And indeed Control shows 'Single' as the Name correctly in the first row of the Grid. However the Control shows nothing in the second row of the Grid.
I'm clearly missing something obvious ...