WPF 嵌套容器
在窗口控件上,我的主要容器是网格。
我的网格有 2 行,一行定义为 50*,另一行定义为 250*。
现在我想添加一个右侧边栏,比如说使用 StackPanel。
我希望 StackPanel 中有一个与 50* 网格行对齐的 ListBox,因此随着窗口高度变大,ListBox 的大小也会变大。
我的问题是,当 ListBox 位于 StackPanel(嵌套在网格内)内部时,我是否可以实现此行为,或者必须将 ListBox 直接放置在网格内?
On a window control, my main container is a grid.
My grid has 2 rows, one row definition is 50*, and the other is 250*.
Now i want to add a right sidebar, lets say with a StackPanel.
I would like to have a ListBox inside the StackPanel that aligns with the 50* grid row, so as the window height gets bigger, the ListBox size will also get bigger.
My question is whether i can achieve this behavior while the ListBox is inside the StackPanel (which is nested inside the grid) or must the ListBox be placed directly inside the grid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
StackPanel
不会垂直拉伸。如果您必须需要一个包装父容器,请使用
Grid
,它将向各个方向扩展(当然,如果您不考虑水平和垂直对齐;))还请查看 面板概述。
StackPanel
does not stretch vertically.If you must need a wrapping parent container, use a
Grid
, which will expand in all directions (if you leave the Horizontal- and VerticalAlignment alone of course ;) )Also check out the Panel Overview on MSDN.