Present ListBox Items Bottom-to-Top

笑着哭i 提交于 2019-12-18 15:18:16

问题


I've searched for quite a while trying to find an answer to this without any results.

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.

Example:

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.

Thanks.


回答1:


Change the ItemsPanel's layout:

<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.



来源:https://stackoverflow.com/questions/9153296/present-listbox-items-bottom-to-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!