假设我们有一个水平方向且宽度为 100 像素的 Stackpanel。
在里面我制作了 11 个宽度为 10px 的方形 Canvas 绘图。
这意味着最后一个正方形将在 View 之外,因为它将扩展堆栈面板宽度 10 像素。所以我希望这个方 block 换行。
是否有控件可以做到这一点? 困难的部分是 Stackpanel 将是动态的,因此如果我调整 WPF 窗口的大小,Stackpanel 将为 50px,这将导致 2 条完整的方形线和第三 strip 有单个方形的线。
我希望这是有道理的。 我该怎么做?
谢谢,乔纳坦
最佳答案
在这种情况下,您需要包裹面板
<WrapPanel Width="100" Orientation="Horizontal">
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
<Button Width="10" Height="20"/>
</WrapPanel>
关于c# - Stackpanel 中的水平方向,Stackpanel 宽度末尾的新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29259544/