Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing DataTemplates inside a UserControl
    primarykey
    data
    text
    <p>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:</p> <p>Error 2 An object of the type "System.Windows.DataTemplate" cannot be applied to a property that expects the type "System.Windows.Controls.ControlTemplate".</p> <p>I have used this successfully in a Window, can the same not be done within a UserControl?</p> <p>So in my UserControl.Resources i have the following data template</p> <pre><code>&lt;DataTemplate x:Key="StiffenerTemplate"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="50" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Grid.Column="0" Text="{Binding Path=Spacing}" /&gt; &lt;TextBlock Grid.Column="1" Text="{Binding Path=Stiffener.Name}" /&gt; &lt;TextBlock Grid.Column="2" Text="{Binding Path=XLeft}" /&gt; &lt;TextBlock Grid.Column="3" Text="{Binding Path=XRight}" /&gt; &lt;TextBlock Grid.Column="4" Text="{Binding Path=XLeft}" /&gt; &lt;TextBlock Grid.Column="5" Text="{Binding Path=XRight}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; </code></pre> <p>and in the main Grid of the Control i have</p> <pre><code>&lt;ItemsControl ItemsSource="{Binding Path=WebStiffeners}" Template="{StaticResource StiffenerTemplate}"/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload