Question

I've a GridView in my Xaml with a given DataTemplate set a StaticResource:

<GridView
        x:Name="itemGridView"
        ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
        ItemTemplate="{StaticResource MyItemTemplate }" 
        SelectionMode="None"
        IsItemClickEnabled="True"
        ItemClick="ItemView_ItemClick"/>

By clicking on a button in the AppBar, I'd like to restyle this template by applying another DataTemplate - MyItemTemplateWide to this particular list.

My datatemplates are stored in an Xaml file referenced as a ResourceDictionary.

I'd like to load the new DataTemplate in the C# codebehind.

Would the DataTemplateSelector help me here (by setting any hidden value in Xaml for example)?

Was it helpful?

Solution

u can create multiple grid view with different template and change visibilty of the grid as per necessaties.

make grid view visible that is in use and make other visibility false

Note: location of gridview to be placed in xaml must be same for all. means gird.row and grid.column must be same for every gridview if placing it in grid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top