wpf 如何垂直制作uniformgrid
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13944322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to make uniformgrid vertically
提问by Calvin
I'm using UniformGridand it's making the items display horizontally. Is there a way to make it display vertically?
我正在使用UniformGrid它使项目水平显示。有没有办法让它垂直显示?
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="3" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
Any help would be greatly appreciated.
任何帮助将不胜感激。
回答by sa_ddam213
The WPF UniformGridlayout is horizontal only, e.g.:
WPFUniformGrid布局仅是水平的,例如:
1 2 3
4 5 6
7 8 9
Perhaps you could use a WrapPanelinstead and just set the ItemHeightand ItemWidthto your desired grid size and set the Orientationto Orientation.Vertical.
也许你可以使用一个WrapPanel来代替,而只设置ItemHeight和ItemWidth您想要的网格大小,并设置Orientation到Orientation.Vertical。
Or you could create a derived UniformGridto handle Orientation, there is a good example on MSDN.
或者您可以创建一个派生UniformGrid来处理Orientation,MSDN 上有一个很好的例子。
This one will display:
这将显示:
1 4 7
2 5 8
3 6 9
Is this what you mean?
你是这个意思吗?
回答by Ralt
I'm a bit late to the party - but for anyone else searching for a solution, the following works.
我参加聚会有点晚了 - 但对于其他任何寻找解决方案的人来说,以下都是有效的。
<UniformGrid Columns="1" />

