Reputation: 3250
I am trying to make ListView with single selection to make selection instantly follow keyboard focus.
I am looking at
However, the only similar documented mode is when focus is moved between elements with keyboard, but to select focused item user needs to hit one more key.
Is there an easy way to make keyboard move both focus and selection.
Upvotes: 1
Views: 955
Reputation: 3250
@AVK's answer is valid for common case. However, instead I had to GotFocus="OnCommandGotFocus"
, probably because my list was grouped.
void OnCommandGotFocus(object sender, RoutedEventArgs e) {
if (e.OriginalSource is ListViewItem command) {
command.IsSelected = true;
}
}
Upvotes: 1
Reputation: 3923
ListView
contains a property called SingleSelectionFollowsFocus
which when set to true
will select the focused item automatically when used with keyboard.
Upvotes: 1