At the time of creating a screen design, we add all the graphics controls that we need, some of they need to be a clickable controls, but.. what happened if not all of your screen controls supports the Click event? For example, some controls as Label, Image… There is a solution! Now I will teach you, how can we make unclickable controls, clickable.
Let’s Start!
Undertanding the XAML structure
? The first thing we have to do, it’s define your graphics control.
? After, inside of the previous tag, you must add another tag with the following structure: ControlName.Gesture
? And to finish, add the TapGestureRecognizer tag. This class makes possible the gesture recognition in the controls.
Using TapGestureRecognizer class
? Tapped Event: Defines the event that will get the control, when the user taps.
? NumberOfTapsRequired property: Defines the number of taps required by the event to be triggered.
Let’s see an example:
XAML:
C# Code:
Good luck with your implementation! ?
Spanish post:
References:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/tap