从下到上显示 ListBox 项 [英] Present ListBox Items Bottom-to-Top
问题描述
我已经搜索了很长一段时间试图找到答案,但没有任何结果.
I've searched for quite a while trying to find an answer to this without any results.
默认的 WPF 列表框添加在顶部对齐的项目,并在其下方添加其他项目.我想要一个以相反方向显示项目的列表框,因此它会添加与底部对齐的项目.
The default WPF Listbox adds items aligned at the top, and additional items below it. I'd like a listbox which presents the items in the opposite direction, so it adds items aligned to the bottom.
示例:
我确信一定有一种更简单的方法,我忽略了它而不重写它,但谷歌似乎没有这个答案,我很难过.
I'm sure there must be a simpler way that I've overlooked to do this without rewriting it all, but Google doesn't seem to have the answer for this one and I'm stumped.
谢谢.
推荐答案
改变ItemsPanel
的布局:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VerticalAlignment="Bottom"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
这与您的图像似乎暗示的一样,添加的第一项仍位于顶部.如果您也想颠倒顺序,那将是一个不同的问题.
This does what your image seems to imply, with the first item added still on top. If you want to reverse the order as well that would be a different issue.
这篇关于从下到上显示 ListBox 项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!