gpt4 book ai didi

c# - Stackpanel 中的水平方向,Stackpanel 宽度末尾的新行

转载 作者:太空狗 更新时间:2023-10-29 20:01:09 25 4
gpt4 key购买 nike

假设我们有一个水平方向且宽度为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com