How can I have a ListBox auto-scroll when a new item is added?

后端 未结 12 2404
走了就别回头了
走了就别回头了 2020-11-28 20:34

I have a WPF ListBox that is set to scroll horizontally. The ItemsSource is bound to an ObservableCollection in my ViewModel class. Every time a new item is added, I want th

12条回答
  •  孤街浪徒
    2020-11-28 21:13

    I found a much simpler way which helped me with a similar problem, just a couple of lines of code behind, no need to create custom Behaviors. Check my answer to this question (and follow the link within):

    wpf(C#) DataGrid ScrollIntoView - how to scroll to the first row that is not shown?

    It works for ListBox, ListView and DataGrid.

提交回复
热议问题