简体   繁体   中英

WinRT - Programmatically tab to next control in C# code behind

Once I successfully validate user data in a TextBox (using TextChanged EventHandler), I'd like to programmatically tab to the next input control. I know I could hard code the name and do

Score2.Focus(Windows.UI.Xaml.FocusState.Keyboard);

but I've got 20 TextBox controls on the page page and I'd like to use the same EventHandler for all of them.

While it may be possible (iterate through the page's control inspecting their tab order and selecting the appopriate next control), I would recommend against it. It will irritate your user if they leave a text box to go back and correct a previous field but your app decides it knows better and gives focus to another field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM