How to capture Pointer Pressed in Button and continuing press?

SmilingMoon 981 Reputation points
2020-12-04T05:06:03.623+00:00

Hello,
I like to create a button allowing user to keep pressing to increase number value, which is a common in mobile app button action for numeric value.

2 questions.

  1. PointerPressed event on Button doesn't fire.
    <Button Name="btPlus"
    Click="btPlus_Click" PointerPressed="btPlus_PointerPressed" >..

=> Click event works, but PointerPressed never fire. How to capture mouse press?

  1. If #1 works, is it possible to keep firing PointerPressed event when user holds mouse press?
    Or, I have to implement the feature with timer along with PointerRelease event?
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yan Gu - MSFT 2,676 Reputation points
    2020-12-04T06:28:50.42+00:00

    Hello,

    Welcome to Microsoft Q&A

    If you want to allow user to keep pressing a button to increase number value, you could use RepeatButton control to replace Button control.

    RepeatButton can raise its Click event repeatedly when it is pressed and held, you could set the RepeatButton.Interval property to set the time, in milliseconds, between repetitions of the click action, as soon as repeating starts.

    You could refer to the document for more information about Button and RepeatButton.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.