user3579594
user3579594

Reputation:

Prevent lost of focus between button clicks in UWP

I'm developing a UWP application that will be used on touchscreen devices. I have a view where users can enter their lunch breaks by tapping on a textbox and clicking one of three buttons that increment the time in the textbox by different amounts (+15 minutes, +30 minutes, etc).

For example the user has had a 45 minute lunch-break they tap on the textbox then tap the +15 minute button then tap the +30 minute button.

My problem is after clicking one button the textbox loses focus and I need to click on the textbox again to regain focus.

Is there a way to prevent the loss of focus between the button clicks?

Upvotes: 3

Views: 820

Answers (1)

Justin XL
Justin XL

Reputation: 39006

It's really simple if you target Anniversary Update (14393) or higher, just set AllowFocusOnInteraction to False on your Button.

<Button Content="Add" AllowFocusOnInteraction="False" />

Upvotes: 2

Related Questions