Hello,
Since the feature of popping up the Flyout window when sliding is provided by the native platform, you need to cancel the Flyout gesture operation on the native platform.
In Maui, you can complete this function through Handler. Please refer to the following documents and sample code.
Step 1. Create a ShellHandler
for Android in the Platform/Android
folder.
public class CustomAndroidShellHandler : ShellRenderer
{
protected override IShellFlyoutRenderer CreateShellFlyoutRenderer()
{
var flyoutRenderer = base.CreateShellFlyoutRenderer();
flyoutRenderer.AndroidView.Touch += AndroidView_Touch;
return flyoutRenderer;
}
private void AndroidView_Touch(object? sender, global::Android.Views.View.TouchEventArgs e)
{
if (e.Event.Action == MotionEventActions.Move)
{
e.Handled = true;
}
else
{
e.Handled = false;
}
}
}
Step 2. Create a ShellHandler
for Android in the Platform/iOS
folder.
public class CustomiOSShellHandler : 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;
}
}
Step 3. Register Handler for builder
in MauiProgram.cs
.
ConfigureMauiHandlers(handlers =>
{
#if IOS
handlers.AddHandler<Shell, CustomiOSShellHandler>();
#elif ANDROID
handlers.AddHandler<Shell, CustomAndroidShellHandler>();
#endif
});
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.