从下到上显示列表框项目 [英] Present ListBox Items Bottom-to-Top

查看:71
本文介绍了从下到上显示列表框项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很长时间,试图找到没有任何结果的答案.

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.

示例:

我敢肯定一定有一种更简单的方法可以忽略而不做全部重写,但是Google似乎没有答案,我很沮丧.

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.

这篇关于从下到上显示列表框项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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