Gul Ershad
Gul Ershad

Reputation: 1771

WPF: Bringing focus back to the TextBox

I tab out from a TextBox and then get an error message due a some validation failure. I press the 'Ok' button acknowledging the error message. Then focus goes on to the next control. How can we have the focus remain on the original TextBox after error has been acknowledged?

Upvotes: 0

Views: 149

Answers (1)

Haseeb Asif
Haseeb Asif

Reputation: 1786

Assuming your text box name txtMybox, you can set the focus of the textbox as follows

txtMybox.Focus()

Upvotes: 2

Related Questions