Phoenix
Phoenix

Reputation: 467

Disable Gestures On Specific Page Xamarin

I am looking to disable gestures for a specific page. I've came across many post suggesting to set MasterDetailPage's IsGestureEnabled to false to disable it. This works but for some reason not all the time.

At the moment I only want to disable gestures at the signin page, so on authentication I enable gestures, OnAppearing I disable.

The issue I'm coming across is that if the user switchs apps and comes back and signs out, the gestures are still enabled. It makes me think a different MasterDetailePage context is being triggered.

Has anyone came across this issue or has any guidance for me. I possibly think I am not understanding the lifecycle of the MasterDetailPage

Upvotes: 0

Views: 215

Answers (1)

Cherry Bu - MSFT
Cherry Bu - MSFT

Reputation: 10356

If you want to disable gestures on a specific page for MasterDetailed Page, I Suggest you try to use MassagingCenter to do this.

1.Using MassagingCenter from master-detailed page constructor:

  MessagingCenter.Subscribe<string>(this, "DisableGesture", (sender) =>
        {
            if (sender == "0")
            {
                IsGestureEnabled = false;
            }
            else
            {
                IsGestureEnabled = true;
            }
        });

2.When you navigate to specific page , and want to disable gesture, you can do this in content page OnAppearing method.

protected override void OnAppearing()
    {
        base.OnAppearing();
        MessagingCenter.Send<string>("0", "DisableGesture");


    }

Upvotes: 2

Related Questions