Hello,
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)
{
base.ViewWillAppear(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;
else
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.