Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 804
Femil Shajin Avatar asked Nov 20 '14 06:11

Femil Shajin


2 Answers

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

like image 117
Tomasz Kowalczyk Avatar answered Nov 20 '22 04:11

Tomasz Kowalczyk


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.

like image 1
dmunch Avatar answered Nov 20 '22 05:11

dmunch