方向更改时GridView重排项目 [英] GridView reflow items on orientation change
问题描述
我是Metro Style开发的新手(因为我没有使用WPF),我正在尝试实现类似于Feed的内容选择"创建您的第一个Metro风格......"教程。这是我的一段XAML代码:
I am new to Metro Style development (as I haven't worked with WPF), and I'm trying to implement something that is like the feed selection in the "Create your first Metro Style..." tutorial. Here is a piece of my XAML code:
<!-- Horizontal scrolling grid used in most view states -->
<ScrollViewer
x:Name="itemGridScrollViewer"
AutomationProperties.AutomationId="GridScrollViewer"
Grid.Row="1"
Margin="0,-4,0,0"
Style="{StaticResource HorizontalScrollViewerStyle}">
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Items"
SelectionMode="None"
IsItemClickEnabled="True"
ItemClick="itemGridView_ItemClick"
Margin="116,0,116,46"
ItemsSource="{Binding Feeds}"
ItemTemplate="{StaticResource DefaultGridItemTemplate}"/>
</ScrollViewer>
这适用于纵向和横向布局。但是如果我以纵向模式启动应用程序,然后我旋转模拟器,GridView中的项目不会重新排列以适应新的布局,因此它会产生奇怪的结果:
This works well in both portrait and landscape layouts. But if I start the app in portrait mode, and then I rotate the simulator, the items in the GridView do not get re-arranged to fit the new layout, so it gives strange results:
我已经尝试过调用InvalidateArrange() ApplicationView.GetForCurrentView()。ViewStateChanged事件,但它没有帮助。
请帮我解决这个问题。
谢谢
I have already tried calling the InvalidateArrange() from the ApplicationView.GetForCurrentView().ViewStateChanged event, but it did not help.
Please help me solving this problem.
Thanks
推荐答案
有趣的问题。
这篇关于方向更改时GridView重排项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!