Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

SwipeGestureRecognizer also enable MasterDetailPage Navigation Drawer?

SreeeeSreeee INMember ✭✭✭✭✭
edited December 2019 in Xamarin.Forms

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?

Best Answer

  • MarcDietersMarcDieters USMember ✭✭
    Accepted Answer

    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;
    }
    

Answers

  • MarcDietersMarcDieters USMember ✭✭
    Accepted Answer

    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;
    }
    
Sign In or Register to comment.