I have user HeaderedItemsControl to display different UserControl in my application.
Now I declared these UserControl with DataTemplate as follows in my MainWindow.
<HeaderedItemsControl.Resources>
<DataTemplate DataType="{x:Type vm:SearchViewModel}">
<vw:SearchStudentView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:SearchViewModel2}">
<vw:SearchStudentView2/>
</DataTemplate>
</HeaderedItemsControl.Resources>
But I have almost 20 view and I want to place all DataTemplate in ResourceDictionary.
Can any one help me how can I use these DataTemplate‘s from ResourceDictionary in HeaderedItemsControl‘s resources?
It’s very simple.
1) You must create and add
DataTemplatetoResourceDictionary.2) In App.xaml file you must add created
ResoueceDictionary(TemplateResourceDictionary.xaml is my testResourceDictionary).That’s all. 🙂