Tapped Gesture in Xamarin Forms


Gesture recognizers can be used to detect user interaction with many elements of a Xamarin.Forms application.

Xamarin.Forms support three different types of recognizers which are:

  • Pinch
  • Pan
  • Tap

In this article we are only covering Tap gesture recognizer.


Introduction To Article:

In xamarin froms you have an option to detect tap gesture of user and perform actions on it. In this article we are going to detect tap gesture and perform actions on it.



Xamarin forms gives us events and properties for this which are used to make it more perfect.

  • Number of taps required

This is a property used to specify number of taps done by a user. you have to give integer value in it.

  • Tapped

Tapped is an event and this event is called when given number of taps are tapped by a user.


let’s go through a simple example in which user can tap on an image and alert is displayed.


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

<StackLayout HorizontalOptions="Center"
 <Image Source="[email protected]" WidthRequest="200" HeightRequest="200">
 <TapGestureRecognizer Tapped="Image_Tapped" NumberOfTapsRequired="2"></TapGestureRecognizer>



 private async void Image_Tapped(object sender, EventArgs e)
 await DisplayAlert("Alert", "You Tappped on me", "OK");


Tap image output

And when you tap on image alert is generated.

Tap image output

XamarinWeb Founder | MVP – C-SharpCorner | Xamarin Forms Developer

Leave a Reply

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