I would like to render a bunch of usercontrols on a Canvas, but each usercontrol should be rendered as the content of a custom content control.
The custom content control is called Window and provides a border, some buttons etc and allows the user to drag the window around the canvas. I've defined the canvas and its children like this:
<ItemsControl Grid.Column="2" Grid.Row="1" ItemsSource="{Binding Views}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:Window Title="Test" Width="300" Height="300" Content="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Top" Value="50"/>
<Setter Property="Canvas.Left" Value="50"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
But when each item is rendered, it's shown without the surrounding Window content control. In fact it doesn't even hit the Window constructor. This says to me that it's ignoring the DataTemplate and just adding the usercontrol to the canvas directly, but I'm not sure why.
Any suggestions?