Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept Enter key in AutoSuggestBox?

'Enter' key in AutoSuggestBox calls to QuerySubmitted event, like clicking the icon. It is a Windows 10 project.

I need to discriminate the Enter key because I use it to go to the next field. I tried KeyDown event, but it is not called.

How can I do it?

like image 450
kokokok Avatar asked Dec 24 '22 12:12

kokokok


1 Answers

Don't ask me why, but you need to use KeyUp event and everything works fine. Ex:

private void ContactsBox_KeyUp(object sender, KeyRoutedEventArgs e)
{
    if (e.Key == Windows.System.VirtualKey.Enter)
    {
        //some stuff here
    }
}
like image 50
Piachu Avatar answered Dec 27 '22 23:12

Piachu