当前位置:网站首页>How to make the listbox scroll automatically when adding a new item- How can I have a ListBox auto-scroll when a new item is added?

How to make the listbox scroll automatically when adding a new item- How can I have a ListBox auto-scroll when a new item is added?

2022-07-05 03:30:00 Bustling city

problem :

I have a WPF ListBox that is set to scroll horizontally. I have one set to scroll horizontally WPF ListBox.The ItemsSource is bound to an ObservableCollection in my ViewModel class.ItemsSource Bound to my ViewModel Class ObservableCollection.Every time a new item is added, I want the ListBox to scroll to the right so that the new item is viewable. Every time you add a new item , I hope ListBox Scroll right , So that you can view new projects .

The ListBox is defined in a DataTemplate, so I am unable to access the ListBox by name in my code behind file.ListBox Is in DataTemplate As defined in , So I can't access by name in my code behind file ListBox.

How can I get a ListBox to always scroll to show a latest added item? How to make ListBox Always scroll to show newly added items ?

I would like a way to know when the ListBox has a new item added to it, but I do not see an event that does this. I want a way to know ListBox When a new item was added , But I don't see the event of this operation .


Solution :

Reference resources : https://stackoom.com/en/question/8Q2b
原网站

版权声明
本文为[Bustling city ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140735558620.html