In Xamarin Forms: I want to be able to detect both click/tap and double-click/tap, and to be able to perform different actions.
That is, when the button is clicked I want to perform actionA
, and when the button is double-clicked I want to perform actionB
, and only actionB
.
Here's what I ended up doing (kudos to Amit Patil):
Do you need an actual button? Else look at the
TapGestureRecognizer
. In this post is described how you can use it. You can apply it to virtually any control.For example if you would style a
Label
to look like a button, you would add a double tap recognizer on it like this:Of course you need to have an event called
OnTapGestureRecognizerTapped
in your code behind. But because of the value in theNumberOfTapsRequired
property, you will need a double tap to activate it.If you prefer code, this would be the counterpart: