I am using the MVVM pattern, I have a view which creates a new ViewModel, after the user clicks save, this view is closed and a seperate view is opened which displays a collection of view models in a ListView.
This ListView is sorted in alphabetical order, so the new ViewModel may appear at the bottom of the ListBox, which is not immediately visible to the user.
My question is how do I get the view to auto scroll to the newly added item?
I guess that It will be using attached behaviours, and the ScrollIntoView event on the ListView, however its which event that I need to capture from the GridView that I am unsure of..
Cheers
This solution is for a ListBox, but it could be modified for a ListView… This will scroll the selected item into view when you change the selected item from the ViewModel.
Class:
Add the xmlns to your view:
Add the style to the resources of the Window/UserControl:
Implement the listbox: