How to detect Left swipe and Right swipe for Stacklayout in Xamarin.Forms?
Solution 1
I have done sample repo on GitHub, let me know what do you think? https://github.com/tkowalczyk/SimpleCustomGestureFrame
Solution 2
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.
Comments
-
Femil Shajin almost 2 years
I have been trying to detect left swipe and right swipe for stacklayout. Things in which I need help are,
- Creating a stacklayout renderer to add swipe Gesture.
- 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
-
Femil Shajin over 9 yearsItz 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.. :)
-
Rodolfo De Los Santos over 8 yearsI 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); }
-
Marek almost 7 yearsRodolfo De Los Santos :+1: