I'm on Windows Phone. I want to replicate the behavior of the calendar app when you create a new event. If you touch the name textbox, and press the enter key of the soft keyboard, the app moves the focus from this textbox to the one just below.
I don't know how to do that in my own app.
I guessed that I had to use the IsTabStop + TabIndex properties, and perhaps the TabNavigation.
But if I set them, it changes nothing.
Like that :
<TextBox IsTabStop="True" TabIndex="1" /> <TextBox IsTabStop="True" TabIndex="2" /> It's a simple behavior, I cannot understand why I'm not able to figure out that alone.
Thanks.
Answer: 1
Use KeyDown event for textBox1. And check for if (e.Key == Key.Enter || e.PlatformKeyCode == 0x0A) and change your focus to another textbox by textBox2.Focus()
Answer: 2
I see two potential ways to do this.
In the first case, you know the fields that comes before and after, so you can hard code the behavior. When the user press "Enter" on textbox1, you focus on textbox2, and so on.
EDIT : This is exactly what said @milan-aggarwal
The second and more generic idea would be to use the VisualTreeHelper (http://msdn.microsoft.com/fr-fr/library/system.windows.media.visualtreehelper.aspx).
When the user press "Enter" (this is easy to detect), using the VisualTreeHelper you look at the children of the englobing panel for the next Textbox (or another type of UI component) to select and focus.
I don't know if there is a native solution to do the same thing.
by : Valryonhttp://stackoverflow.com/users/658883
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog