GridView方向与WinRT中的换行 [英] GridView Orientation with Wrapping in WinRT
问题描述
我希望我的项目水平排列,然后(到达时(当到达时) (简单: 只有垂直滚动条可以显示)。
不幸的是,我当前的xaml只能在一行中添加水平的项目(带有水平滚动条)
< GridView x:Name =GridChildItem
ItemContainerStyle ={StaticResource NonTickGridViewItem}
VerticalContentAlignment =Stretch
ItemTemplate ={StaticResource CustomChildItemTemplete}
SelectionMode =Single
IsItemClickEnabled =True
ItemClick =gridViewChild_ItemClick_1
Margin =0,40,0,0
Height =Auto
Background ={ StaticResource DropDownMe nuBackColor}
ScrollViewer.IsHorizontalScrollChainingEnabled =False
ScrollViewer.IsVerticalScrollChainingEnabled =True
VerticalAlignment =Top>
< GridView.ItemsPanel>
< ItemsPanelTemplate>
< StackPanel Orientation =HorizontalMargin =20,0,0,0/>
< / ItemsPanelTemplate>
< /GridView.ItemsPanel>
< / GridView>
如果您不想让水平滚动需要使用 ListView
而不是 GridView
,
< a href =http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.listview.aspx>来自MSDN:
使用 ListView 显示垂直滚动
的数据集合。要显示水平滚动的集合,请使用
GridView 。
但是,如果您想要保持您使用 WrapGrid 所需的包装行为作为 ItemsPanel
:
< ListView>
< ListView.ItemsPanel>
< ItemsPanelTemplate>
< WrapGrid方向=水平/>
< / ItemsPanelTemplate>
< /ListView.ItemsPanel>
< / ListView>
I am developing a WinRT app in c# , I am using a GridView to present my item.
I want my items to be arranged Horizontally and then(when reached the max width) next items should be added to the new row(Simply: only vertical scroll-bars can be visible).
Unfortunately my current xaml can only add items horizontal in one row(with a horizontal scroll bar)
<GridView x:Name="GridChildItem"
ItemContainerStyle="{StaticResource NonTickGridViewItem}"
VerticalContentAlignment="Stretch"
ItemTemplate="{StaticResource CustomChildItemTemplete}"
SelectionMode="Single"
IsItemClickEnabled="True"
ItemClick="gridViewChild_ItemClick_1"
Margin="0,40,0,0"
Height="Auto"
Background="{StaticResource DropDownMenuBackColor}"
ScrollViewer.IsHorizontalScrollChainingEnabled="False"
ScrollViewer.IsVerticalScrollChainingEnabled ="True"
VerticalAlignment="Top">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
If you don't want to allow horizontal scrolling you need to use ListView
instead of GridView
,
Use a ListView to display a collection of data that scrolls vertically. To display a collection that scrolls horizontally, use a GridView.
But if you want to keep the wrapping behavior you need to use WrapGrid as the ItemsPanel
:
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
这篇关于GridView方向与WinRT中的换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!