How to Scroll to the Bottom of a ListBox when Items are Added

早过忘川 提交于 2019-12-25 10:25:14

问题


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?


回答1:


listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;


来源:https://stackoverflow.com/questions/22374331/how-to-scroll-to-the-bottom-of-a-listbox-when-items-are-added

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