Windows 8中的ListView与水平的项目流 [英] Windows 8 ListView with horizontal item flow
问题描述
我怎样才能把窗里面ListItems的8 ListView控件在水平方向流动。默认行为是垂直的,但我想,以显示水平流动的列表,以便它可以为全景呈现。
How can i make the ListItems inside windows 8 ListView to flow horizontally. Default behavior is vertical, but i want to show the list in horizontal flow so it can render as panorama.
我试过的GridView其不支持横向布局,但没有对项目的高度限制不显示有大量的文字项完整的项目内容。
I tried GridView which does support horizontal layout but there is a limitation on item height which does not show the complete item content for items with large text.
推荐答案
您可以使用一个ListView是这样的:
You can use a ListView this way:
<ListView
Height="500"
VerticalAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.ZoomMode="Disabled"
SelectionMode="None">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
- 给它一个水平板和水平滚动条滚动条权
-- that gives it a horizontal panel and the right ScrollBars for horizontal scrolling.
当你得到较大的项目都ListView和GridView控件可能会导致问题。我认为,在默认情况下的项目可能根据尺寸的第一项增加的大小。您可以在大小设置手动,但:
Both ListView and GridView can cause problems when you get larger items. I think by default the items might be sized based on the size of the first item added. You can set that size manually though:
<ListView.ItemContainerStyle>
<Style
TargetType="ListViewItem"><!-- note - for GridView you should specify GridViewItem, for ListBox - ListBoxItem, etc. -->
<Setter
Property="Height"
Value="200" /> <!-- this is where you can specify the size of your ListView items -->
<Setter
Property="Width"
Value="350" />
</Style>
</ListView.ItemContainerStyle>
- 注意,所有物品需要具有相同的尺寸
-- note that all items need to be the same size.
- 也注意到 - 我已经改变了这个答案替换的StackPanel
与 ItemsStackPanel
这是虚拟化的,所以它应该让你更好的性能和大型数据集更低的内存使用量,但请 - 不创建大,水平滚动列表布局。他们可能是在一些非常有限的情况下很好的解决方案,但在大多数情况下,他们将打破许多好的UI模式,使您的应用程序更难使用。
-- also note - I have changed this answer to replace a StackPanel
with an ItemsStackPanel
which is virtualized, so it should get you better performance and lower memory usage for large data sets, but PLEASE - don't create layouts with large, horizontally scrollable lists. They might be a good solution in some very limited scenarios, but in most cases they will break many good UI patterns and make your app harder to use.
这篇关于Windows 8中的ListView与水平的项目流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!