Xamarin.Forms Guides | Samples

Xamarin.Forms.View.GestureRecognizers Property

The collection of gesture recognizers associated with this view.

Syntax

public IList<IGestureRecognizer> GestureRecognizers { get; }

Value

A List of IGestureRecognizer.

Remarks

Adding items to this collection will associate gesture events with this element. This is not nessesary for elements which natively support input, such as a Button.

This example creates a tap gesture recognizer and associates it with an image. When the image is double tapped, it will become semi-transparent.

C# Example

  var image = new Image {Source = "image.png"};
  var gestureRecognizer = new TapGestureRecognizer {
    TappedCallback = o => image.Opacity = 0.5,
    NumberOfTapsRequired = 2
  };
  image.GestureRecognizers.Add (gestureRecognizer);

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0