Eugene
Eugene

Reputation: 2985

How do I keep focus on TextBox after a button was pushed?

I have a XAML ListBox, a TextBox inside the ItemTemplate. A user edits text inside the TextBox, and then presses a button in the application bar. How do I keep the focus on the TextBox after the button in the application bar was pushed?

Upvotes: 0

Views: 365

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 65564

You don't. You set it back afterwards.

You can use Focus() method to do this.

You can also use the SelectionStart and SelectionLength to highlight a specific part of the text.

Upvotes: 3

Related Questions