WPF收缩子面板
我正在为 WPF 应用程序开发 UI。我的窗口堆栈面板中有一些扩展器。每个扩展器中都有一些控件,其中一个是列表框。我想要做的是在调整窗口大小时调整列表框的大小(缩小或增大)。目前,当我重新调整大小时,扩展器被剪掉,但列表框(有时高度很长)保持不变。我该如何去做才能实现这一点。
一个很好的例子是在 Outlook 2007 中,左侧的“邮件文件夹”会随着窗口大小而缩小,但其他控件不会。
提前致谢。
I'm working on a UI for a WPF application. I have in my window Stack Panel with some Expanders inside. In each Expander are some controls, one being a List Box. What I want to do is have the List Box resize (shrink or grow) when the window is resized. At the moment, when I re-size, the expander are getting clipped off but the listbox (sometimes very long in height) remains unchanged. How do I go about making this happen.
A good example is in Outlook 2007, the "Mail Folder" on the left shrinks with window size but the other controls don't.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
StackPanel 不会强制其子级的高度 - 它允许每个子级调整其喜欢的大小。您可以尝试在扩展器周围使用网格,并为每行指定星形高度,以便调整内容的大小。
The StackPanel won't push a height on its children - it allows each child to size as big as it likes. You might try using a Grid around the Expanders, and giving each Row a star height so that the contents resize.
谢谢保罗,
我自己发现了一些有趣的东西。
我用一个简单的方法扩展了网格控件,该方法在扩展器展开时触发,我称之为。
<代码>
这非常有效。
Thanks Paul,
I've found something interesting myself.
I've extended the grid control with a simple method that fires when the expander is expanded, I would call this.
This worked very nicely.