Let ListView scroll to selected item

前端 未结 2 898
南笙
南笙 2021-01-18 07:46

I have a WinRT/C#/XAML app with a view that has a vertical ListView of items. Depending on the amount of items the ListView shows a vertical scrollbar. Here\'s the XAML defi

2条回答
  •  天命终不由人
    2021-01-18 07:51

    I had a similar need and resolved it in a slightly different manner. I subscribed to the SelectionChangedEvent from the ListView and performed the scrolling within the handler.

    XAML:

    
    
    

    Code:

    private void myListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        myListView.ScrollIntoView(myListView.SelectedItem);
    }
    

提交回复
热议问题