Dzmitry Shauchuk
Dzmitry Shauchuk

Reputation: 454

UWP: Raise Key Down programmatically

I want to manage the listview while the text field is in focus. I mean the following case: I'm writing some text into the text box, but I am able to manage the list view selection in the same time by some keys(Up, Down).

I tried to change the SelectedIndex property, but I lose the automatic scrolling of the list view in this case.

I think it could be solved by raising key down event with a special key (Up, Down) for the listview - is there any way to do it?

Upvotes: 0

Views: 77

Answers (1)

Muhammad Touseef
Muhammad Touseef

Reputation: 4465

you just need to use ScrollIntoView() method of ListView whenever you set the SelectedIndex of your ListView just follow it up with ScrollIntoView. you do it in 2 ways.

  1. subscribe to SelectionChanged event and scroll the new selected item into view.
  2. instead of setting SelectedIndex you can set SelectedItem and then scroll that item into view.
  3. After setting the SelectedIndex, just get the item of that index and then scroll that item into view.

Upvotes: 2

Related Questions