3
votes

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?

1
With in the button click event, after performing your logic call the textbox to take back focus. Once you click the button you will loose textbox focus. That is by design. Doesn't mean you cannot set it back after.Nkosi

1 Answers

2
votes

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" />