在 StackPanel wpf 中包装内容 [英] wrapping content in a StackPanel wpf
问题描述
是否可以将内容包装在 StackPanel
中?
is it possible to wrap content in a StackPanel
?
我知道我们可以使用 WrapPanel
代替.但出于代码修改的原因,我必须使用 StackPanel
.
I know that we can make use of a WrapPanel
instead.
But for code modifying reasons, I must make use of a StackPanel
.
那么,有没有办法让 StackPanel
中的项目在 5 个项目之后包装...谢谢!
So, is there a way to make the items in a StackPanel
wrap after say 5 items...
Thanks!
推荐答案
创建嵌套的 StackPanel
包含所需数量的项目.
Create nested StackPanel
s which contain the required number of items.
在下面的示例中,您有两行,分别由 <StackPanel Orientation="Horizontal">
元素占据,这些元素依次包含五个将在旁边水平显示的项目彼此.
In the example below, you have two rows, respectively occupied by the <StackPanel Orientation="Horizontal">
elements, which in turn each contain five items that will be displayed horizontally next to each other.
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Item1 />
<Item2 />
<Item3 />
<Item4 />
<Item5 />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Item1 />
<Item2 />
<Item3 />
<Item4 />
<Item5 />
</StackPanel>
</StackPanel>
这篇关于在 StackPanel wpf 中包装内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!