question

Voytec-6484 avatar image
0 Votes"
Voytec-6484 asked Voytec-6484 commented

UWP C# Keyboard input focus

Greetings !!! :-)

Today's question:
How to return keyboard's input focus back to a TextBox which has been enabled again?

windows-uwp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please share more details about your scenario? Based on your words, I know that you want to make a TextBox focused. I'm confused about what you mean by return keyboard's input focus.

0 Votes 0 ·

Ok, let's try this way:
I start my new app and write something into a TextBox, then I hit enter, disable that TextBox, calculate something with code, enable TextBox again, and I want to write something into our TextBox again withou clicking it with mouse - back to typing focus.
I hope this explains what I mean and THANKS!
xD

0 Votes 0 ·

1 Answer

RoyLi-MSFT avatar image
1 Vote"
RoyLi-MSFT answered Voytec-6484 commented

Hello,

Welcome to Microsoft Q&A!

Based on your scenario, you could just call the TextBox.Focus() Method to make the TextBox focus again. It's just a simple line of code and you could put it after you enable the TextBox.

For example:

             MyTextBox.IsEnabled = true;
             MyTextBox.Focus(FocusState.Programmatic);

Thank you.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.