In our Windows Store app we have a textbox, and when the application starts this textbox always get focus. In a desktop scenario that's no problem, but on a tablet device this focus will directly open the onscreen keyboard which is not a scenario that we want.
We tried to set the focus on another control programmatic with the .Focus(FocusState) method, but somehow the focus is set back to the textbox. We have both set the focus in the LoadState or the OnNavigatedTo method.
Only when we have timer we have set the focus succesfully to another control. Anyone has ideas how to set the focus to another control, or preferably set not focus at all to an control?
The blur() method removes focus from an element.
If you want to remove the focus around a button, you can use the CSS outline property. You need to set the “none” value of the outline property.
Normally you can set the Focus on any element by TextBox.Focus()
. However I discovered the same behaviors (autofocus on start) when you place your TextBox inside a ScrollViewer or a FlyOut. Then you have to set the IsTabStop on the parent-element:
<ScrollViewer IsTabStop="true">
<TextBox />
</ScrollViewer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With