Events, Xamarin

Making clickable graphic controls with TapGestureRecognizer

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.GestureRecognizersGestureRecognizer property is a collection of gesture recognizers associated with an specific graphic control, in this case, the Image.

?   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:


C# Code:

Good luck with your implementation! ?

Spanish post:áficos-con-tapgesturerecognizer-6d389be9a2d8


Tagged , ,

Leave a Reply

Your email address will not be published. Required fields are marked *