Reputation: 2528
When I enable keyboard access and I scroll the listview programatically to item nr 50, I want to set the focused item to nr 50 so if the user presses the down arrow he will scroll from nr 50 and down. Currently the list jumps to nr 1 since that item is focused.
I have tried setting the selectedItem property to 50, but still the same behavior.
This solution seems to work for HTML/JS apps but I don't see the same API with C#? how to set a focus of Listview item in Metro apps?
yourListView.currentItem = { index: 8, hasFocus: true, showFocus: true }
Upvotes: 0
Views: 1097
Reputation: 11
Here's a code snippet for you:
ListViewItem^ selectedListItem = static_cast(yourListView->ContainerFromIndex(RecipientList->SelectedIndex));
selectedListItem->Focus(Windows::UI::Xaml::FocusState::Pointer);
Upvotes: 1
Reputation: 7037
Use the ScrollIntoView method.
yourListView.ScrollIntoView(dataItem);
where dataItem is a reference to the item you want to see.
It's a little different if the ListViiew is in a SemanticZoom container. The you have to call MakeVisible() method.
Upvotes: 0