Search code examples
wpftextboxsetfocus

SetFocus to a textbox wpf


I want to set focus to a textbox always. I am creating a application in wpf, in the search page there is a textbox i want to set focus to that textbox always, if the user clicks anywhere in the page the taxtbox should gain the focus. How to achieve this task.

Geetha.


Solution

  • Despite the solution of handling the LostKeyboardFocus and LostKeyboardFocus and set the focus to the same element again using Keyboard.Focus method, you can find a lot of advices and other solutions here