WPF ListBox Scroll to end automatically

后端 未结 9 798
耶瑟儿~
耶瑟儿~ 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:17

    The best solution is to use the ItemCollection object inside the ListBox control this collection was specially designed to content viewers. It has a predefined method to select the last item and keep a cursor position reference....

    myListBox.Items.MoveCurrentToLast();
    myListBox.ScrollIntoView(myListBox.Items.CurrentItem);
    

提交回复
热议问题