使用什么 WPF 面板控件将子项锚定到边缘(手风琴效果)?
这(希望)是一个简单的...我正在尝试找到一个可以使用的 WPF 面板,当调整大小时,它会保持所有垂直对齐的子项(按钮)与面板底部边缘的偏移距离相同,因此它看起来他们正在扩张。
最明显的方法是使用停靠面板并锚定到底部,但这似乎不起作用。将两个以上的孩子放在那里会弄乱对齐方式,无论我做什么,我都无法让它们垂直对齐。我尝试过各种面板,但没有任何乐趣。我认为这相当简单,但它难倒了我!
基本上,当我单击顶部按钮时,我试图获得手风琴效果,面板会展开并显示所有子按钮。当我再次单击顶部按钮时,它会折叠。我想我可以用故事板移动每个孩子,但我必须认为我的故事需要做的就是改变面板的大小,并且孩子们保持他们的偏移和手风琴......
有什么想法吗?
提前致谢!
This (hopefully) is an easy one... I'm trying to find a WPF panel that I can use that when resized keeps all it's vertically aligned children (buttons) offset the same distance from the bottom edge of the panel, so it looks like they are expanding.
The obvious one is to use a dock panel and anchor to the bottom but this doesn't seem to work. Putting more that 2 children in there messes up the alignment and whatever I do I can't get them vertically lined up. I've tried all sorts of panels but have had no joy. I'm assuming it's fairly straightforward but it's stumped me!
Basically I'm trying to get a concertina effect when I click the top button the panel expands and shows all the sub buttons. And when I click the top button again it collapses. I guess I can move each of the children with a storyboard but I have to think all my story needs to do is change the size of the panel and the children maintain their offsets and concertina out...
Any ideas?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果“基本上我想获得手风琴效果”是您问题的本质(我对吗?)那么,您是否尝试过使用内置的 WPF 扩展器?在我看来,你正试图建立自己的......
If "Basically I'm trying to get a concertina effect" is the essence of your question (Am I right ?) then, did you tried tu use an built-in WPF expander ? It seems to me that you are trying to build up your own...
我相信你实际上可以使用Canvas并设置控件的Canvas.Top、Left、Right和Bottom属性来获得与WinForms和anchor相同的效果。
Grid 也可以执行类似操作:
I believe you can actually use a Canvas and set the Canvas.Top, Left, Right, and Bottom properties of the controls to get the same effect as WinForms and anchor.
Also Grid can do similar:
我不太明白你所说的手风琴效应是什么意思,它也可能与拉伸有关。如果你想要锚定,你可以使用网格:
I do not quite get what you mean by concertina effect, it could have to do with stretching as well. If you want anchoring you can use a Grid: