Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove focus on first textbox

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?

like image 891
ChristiaanV Avatar asked Aug 08 '13 08:08

ChristiaanV


People also ask

How do you remove the focus element?

The blur() method removes focus from an element.

How do I turn off focus button?

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.


1 Answers

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>
like image 172
Jan Hommes Avatar answered Jan 02 '23 15:01

Jan Hommes