Preventing loss of focus between button clicks in UWP

I am developing a UWP app that will be usable on touch devices. I have a view where users can enter their lunch breaks by clicking on the text box and clicking one of three buttons that increment the time in the text box by different amounts (+15 minutes, +30 minutes, etc.).

For example, a user had a 45 minute lunch break that they click on the text box, then click the +15 minutes button, then click the +30 minutes button.

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

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

+3


source to share


1 answer


It's really easy, if you are targeting the Anniversary Update (14393) or higher, just set AllowFocusOnInteraction

to False

on Button

.



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

      

+3


source







All Articles