添加项目时如何滚动到列表框的底部 [英] How to Scroll to the Bottom of a ListBox when Items are Added
本文介绍了添加项目时如何滚动到列表框的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够在我拥有的ListBox中创建某种自动滚动功能,其中新数据会定期添加到ListBox中.填充ListBox的项目保存在ObservableCollection中,并且始终添加到集合的末尾.每当将新项目添加到ObservableCollection并更新View时,是否有办法使ListBox自动滚动到底部?
I'd like to be able to create some sort of auto scrolling feature in a ListBox I have, where new data is added periodically to the ListBox. Items populating the ListBox are held in an ObservableCollection, and are always added to the end of the collection. Is there a way to make the ListBox auto scroll to the bottom every time a new item is added to the ObservableCollection and the View is updated?
推荐答案
listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;
这篇关于添加项目时如何滚动到列表框的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文