Building a CustomRenderer for native gestures

Now we need to handle swipe left and right gestures for each mobile platform. Unfortunately, Xamarin.Forms doesn't offer a cross-platform feature for swipe gestures, so we need to implement this ourselves. In order to do this, we are going to build a CustomRenderer. Start by adding a new file to the Controls folder called GestureView.cs and implement the following:

public class GestureView : View { public event EventHandler SwipeLeft; public event EventHandler SwipeRight; public event EventHandler Touch; public void NotifySwipeLeft() { if (SwipeLeft != null) { SwipeLeft (this, EventArgs.Empty); } } public void NotifySwipeRight() { if (SwipeRight != null) { SwipeRight (this, EventArgs.Empty); } } public ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.