Disable Xamarin Shell Flyout swipe gesture.

Abraham John 111 Reputation points

I'm using Flyout page using Shell. My home page is a carouselview page. Some times when we swipe the carouselview right, the Flyout page appears. Is there any way to disable swipe gesture for Flyout page so that carouselview can be swiped without any disturbance?

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,015 questions
0 comments No comments
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,736 Reputation points


    Welcome to Microsoft Q&A!

    We can disable the swipe gesture in custom renderer , but it may need to use Reflection to seek private property.

    iOS Solution

       [assembly: ExportRenderer(typeof(AppShell), typeof(iOSShellRenderer))]  
           namespace TestMenuSwipe.iOS  
                           public class iOSShellRenderer : ShellRenderer  
                                           IShellFlyoutRenderer flyoutRenderer;  
                                           protected override IShellFlyoutRenderer CreateFlyoutRenderer()  
                                                           flyoutRenderer = base.CreateFlyoutRenderer();   
                                                           return flyoutRenderer;  
                                           public override void ViewWillAppear(bool animated)  
                                                           var type = flyoutRenderer.GetType();  
                                                           var property = type.GetProperty("PanGestureRecognizer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);  
                                                           var value = property.GetValue(flyoutRenderer);  
                                                           UIPanGestureRecognizer recognizer = value as UIPanGestureRecognizer;  
                                                           recognizer.Enabled = false;  

    Android Solution

       [assembly: ExportRenderer(typeof(AppShell), typeof(AndroidShellRenderer))]  
           namespace TestMenuSwipe.Droid  
                           public class AndroidShellRenderer : ShellRenderer  
                                           public AndroidShellRenderer(Context context) : base(context)  
                                           protected override IShellFlyoutRenderer CreateShellFlyoutRenderer()  
                                                           var flyoutRenderer = base.CreateShellFlyoutRenderer();  
                                                           flyoutRenderer.AndroidView.Touch += AndroidView_Touch;                                          
                                                           return flyoutRenderer;  
                                           private void AndroidView_Touch(object sender, Android.Views.View.TouchEventArgs e)  
                                                           if (e.Event.Action == MotionEventActions.Move)  
                                                                           e.Handled = true;  
                                                                           e.Handled = false;  

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

3 additional answers

Sort by: Most helpful
  1. jeanie77 1 Reputation point

    @Cole Xia (Shanghai Wicresoft Co,.Ltd.)

    I have the same problem (I guess), but the suggested solution doesn't disable swipe between tabs.
    Here is my AppShell content with the suggested renderer:

    <?xml version="1.0" encoding="UTF-8"?>  
    <Shell xmlns="http://xamarin.com/schemas/2014/forms"   
        <!-- tabbed topbar -->  
        <FlyoutItem Title="Routes" Icon="maps.png">  
                <ShellContent Title="Summary"  
                              ContentTemplate="{DataTemplate views:SummaryPage}" Route="SummaryPage" />  
                <ShellContent Title="Directions"  
                              ContentTemplate="{DataTemplate views:DirectionsPage}" />  
        <MenuItem Text="Logout" Icon="logout.png" Clicked="onLogoutClicked" />  

    I tried to follow these guidelines to override CreateShellSectionRenderer in the suggested Shell renderer, but I don't know where to attach the Touch event, in order to disable swipe between section contents. Could you please provide a sample, if this is supported? Thank you.

    0 comments No comments

  2. jeanie77 1 Reputation point

    anybody there?...

    0 comments No comments

  3. viktor kalder 1 Reputation point


    0 comments No comments