WPF StackPanel 如何从底部到顶部垂直填充? [英] How can a WPF StackPanel fill vertically from bottom to top?

查看:38
本文介绍了WPF StackPanel 如何从底部到顶部垂直填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够用 buttons 填充 stackpanel 但按钮必须先出现在 stackpanel 的底部并向上填充.这些按钮是动态创建的,并且它们的数量未知,因此视觉黑客是行不通的.我试过尝试垂直对齐,但无济于事.

I need to be able to fill a stackpanel with buttons but the buttons must appear at the bottom of the stackpanel first and populate upwards. The buttons are created dynamically and there's an unknown number of them so visual hackery just won't work. I've tried experimenting with vertical alignments but to no avail.

推荐答案

像这样:

<StackPanel VerticalAlignment="Bottom">
    ...
</StackPanel>

要向上填充按钮,您必须在位置 0 插入按钮,而不是添加它们.

and to populate with buttons upward you must insert the buttons at position 0, instead of adding them.

这篇关于WPF StackPanel 如何从底部到顶部垂直填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆