WPF ListBox Scroll to end automatically

后端 未结 9 815
耶瑟儿~
耶瑟儿~ 2020-12-13 08:25

In my application, I have a ListBox with items. The application is written in WPF.

How can I scroll automatically to the last added item? I want the

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 09:11

    Try this:

    lstBox.SelectedIndex = lstBox.Items.Count -1;
    lstBox.ScrollIntoView(lstBox.SelectedItem) ;
    

    In your MainWindow, this will select and focus on last item on the list!

提交回复
热议问题