xamarin.formsnavigation-drawermaster-detailuiswipegesturerecognizer

Xamarin forms: SwipeGestureRecognizer also enable MasterDetailPage Navigation Drawer?


I have implemented the swiping feature using SwipeGestureRecognizer on my homepage. But the problem is the home page is a child of a MasterDetailPage. So when I swipe to left in the homepage, the navigation drawer is also coming to UI. I have tried like below to stop showing navigation drawer on UI when doing SwipeGestureRecognizer using MessagingCenter, but no luck!!!

On Homepage

public void Swipe(object sender, EventArgs e)
{
    MessagingCenter.Send<HomePage>(this, "HomePageSwipe");
    //code for swipe
}

On MasterDetailPage Constructor

MessagingCenter.Subscribe<HomePage1>(this, "HomePageSwipe", (sender) =>
{
    IsPresented = false;
    NavigationPage.SetHasNavigationBar(this, false);
});

Is there any way to fix this?


Solution

  • I believe this behavior occurs only on ios. To disable this, you need to add this to the OnAppearing() method

    if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS)
    {
        IsGestureEnabled = false;
    }