I have a UserControl that becomes a page in an XPS report. Part of the page is a table which is populated from a List. I have created a DataTemplate for each row of the table. However when i assign the Template to a ListView or ItemsControl i get the following error:
Error 2 An object of the type "System.Windows.DataTemplate" cannot be applied to a property that expects the type "System.Windows.Controls.ControlTemplate".
I have used this successfully in a Window, can the same not be done within a UserControl?
So in my UserControl.Resources i have the following data template
<DataTemplate x:Key="StiffenerTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=Spacing}" />
<TextBlock Grid.Column="1" Text="{Binding Path=Stiffener.Name}" />
<TextBlock Grid.Column="2" Text="{Binding Path=XLeft}" />
<TextBlock Grid.Column="3" Text="{Binding Path=XRight}" />
<TextBlock Grid.Column="4" Text="{Binding Path=XLeft}" />
<TextBlock Grid.Column="5" Text="{Binding Path=XRight}" />
</Grid>
</DataTemplate>
and in the main Grid of the Control i have
<ItemsControl ItemsSource="{Binding Path=WebStiffeners}"
Template="{StaticResource StiffenerTemplate}"/>