Xaml 旋转设备时,如何更改GridView的ItemsPanelTemplate?
我有一个带有ItemsStackPanel的GridView,我想在设备旋转时更改其方向。例如,如果ItemsPanelTemplate定义为:Xaml 旋转设备时,如何更改GridView的ItemsPanelTemplate?,xaml,gridview,windows-runtime,Xaml,Gridview,Windows Runtime,我有一个带有ItemsStackPanel的GridView,我想在设备旋转时更改其方向。例如,如果ItemsPanelTemplate定义为: <GridView.ItemsPanel> <ItemsPanelTemplate> <ItemsStackPanel GroupPadding="0,0,70,0" Orientation="Horizontal"/> </ItemsPanelTemplate> <
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel GroupPadding="0,0,70,0" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
我想通过编程将其转换为:
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel GroupPadding="0,0,70,0" Orientation="Vertical"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
我不知道如何直接访问此对象。最好的方法是创建两个要使用的视图。查看Visual Studio 2012提供的网格应用程序模板。它有一个GridView和一个ListView。捕捉设备时,隐藏GridView并通过VisualState显示ListView