Bogdan Bujdea

Windows Platform Developer

How to open the keyboard when using TextBox.Focus in UWP

I’m working on a small Romanian news reader and I encountered a problem when I was trying to focus on a text box control. The flow was like this:

  • click on “Search” button from the app bar
  • TextBox from header gets focused and the keyboard is opened

I was using this piece of code to focus on it:



However, the keyboard was not opening, and I haven’t found the answer on Google, that’s why I wrote this small post.

In order to fix it, just add a small delay, like 100 milliseconds before focusing on it and it will work, so the final code looks like this:


            await Task.Delay(100);

, , ,