Keep focus textbox

46 Views Asked by At

I would like to keep focus on the textbox when it is collapsed because I use barcode reader. I do it by setting the focus again in the lost focus event using the extra bool variable. This works fine. However, I would like to change the value of this variable when the hambuger menu item is clicked. Anyone have any idea how to do this or please give me a hint where the focus is if no element on the page has it? Is it Frame? The minimum version of win 10 in my project is 10536 and so it must be so I can not use the many amenities of later versions. greetings

1

There are 1 best solutions below

0
Richard Zhang On

For controls in UWP, there are two prerequisites for getting focus:

  1. Can interact with the user (so Grid, etc. Panel can't get focus).
  2. Display in the visualization tree.

So if you set the Visibility property of the TextBox to Collapsed, it won't get the focus.

Also, if this feature is important to you, we recommend that you upgrade to a newer system.

In the system version of 15063 and above, the FocusManager is provided to help you manage the focus of the control better.

Best regards.