How to Scroll to the Bottom of a ListBox when Item

2019-09-09 14:11发布

问题:

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;