How to detect Left swipe and Right swipe for Stacklayout in Xamarin.Forms?

12.1k Views Asked by At

I have been trying to detect left swipe and right swipe for stacklayout. Things in which I need help are,

  1. Creating a stacklayout renderer to add swipe Gesture.
  2. How to detect user has swiped left or right.

Please provide a solution which works on cross platforms.

Providing an example for stacklayout renderer will be really helpful to acheive the swipe functionality in xamarin.forms

2

There are 2 best solutions below

3
On BEST ANSWER

I have done sample repo on GitHub, let me know what do you think? https://github.com/tkowalczyk/SimpleCustomGestureFrame

0
On

StackLayout like all the other layout classes doesn't have a renderer, since the layout is completely handled by Xamarin.Forms itself without any help of native layout engines.

What you might do to achieve what you're looking for is to implement a custom renderer for a Frame and implement your swipe gestures on it. You could then put your StackLayout into the Frame and you should be settled.