I have different data templates defined in my App.xaml with diffrent names (temp1, temp2, temp3). Now I want to apply these templates to an GridView.
So I’m using
GridV.ItemTemplate = (DataTemplate)FindName("temp1");
where GridV is the name of the GridView. But now I didn’t get the right output. I’m getting only the type of the item, but not the informationwhich are linked to the data template. What can I do now?
If you have declared your templates inside the resources dictionary in App.xaml then you can retrieve and set them on your GridView, like this:
GridV.ItemTemplate = (DataTemplate)App.Current.Resources[“temp1”];