6

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

Nuri YILMAZ
  • 4,291
  • 5
  • 37
  • 43
Femil Shajin
  • 1,768
  • 6
  • 24
  • 38

2 Answers2

4

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

Tomasz Kowalczyk
  • 1,873
  • 2
  • 23
  • 33
  • Itz good. It serves the purpose. Thanks for your repo. Very Useful one, But have to tried to detect swipe inside carasoul page?? Horizontal scroll is not being detected in carasoul page coz it already has swipe gesture. Just shared this fact because I noticed it.. Disabling the gesture of carasoul will solve this problem.. Again Thanks.. :) – Femil Shajin Nov 21 '14 at 07:21
  • 1
    I had to override DispatchTouchEvent and call the the GestureDetector from there to get it to work. public override bool DispatchTouchEvent(MotionEvent e) { _detector.OnTouchEvent(e); return base.DispatchTouchEvent(e); } – Rodolfo De Los Santos Sep 15 '15 at 20:09
  • Rodolfo De Los Santos :+1: – Marek Jul 11 '17 at 08:09
1

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.

dmunch
  • 384
  • 2
  • 5