How do you handle tap gestures on any view in MAUI?
Short answer
Add a TapGestureRecognizer to a view's GestureRecognizers and bind its Command (or handle Tapped). This lets non-button elements like images or labels respond to taps, and NumberOfTapsRequired supports double-tap.
Advertisement
AModel answer
Add a TapGestureRecognizer to a view's GestureRecognizers and bind its Command (or handle Tapped). This lets non-button elements like images or labels respond to taps, and NumberOfTapsRequired supports double-tap.
<Image Source="heart.png">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding LikeCommand}" />
</Image.GestureRecognizers>
</Image>Real-world example
A like button made from an Image responds to taps via a gesture recognizer bound to a command.
Likely follow-ups
- How do you detect a double tap? | Which views support gestures?
Related topics