WPF ListView Show selected item

Jeffrey picture Jeffrey · Jul 18, 2009 · Viewed 21.3k times · Source

I want to show the selected item in a list view automatically(it isn't possible to show all items without scrolling).

this.listView.SelectedIndex = 999; selects of course an item, but it doesn't show it.

what can I use to show it automatically ?

kind regards, jeff

Answer

user1360355 picture user1360355 · Aug 26, 2015

You can do this:-

listview.ScrollIntoView(listview.SelectedItem);

Scroll WPF ListBox to the SelectedItem set in code in a view model