1

how can I lock the flyout menu when an activity indicator is currently running. I want, if there is a calculation on a page, to lock the menu, so that the user has to wait until the calculation is finished. In this time, when I display a running activity indicator, the user should have no possibility to open the menu or to change the page.

How can this be done?

Thank you in advance!

nicetomitja
  • 145
  • 10

1 Answers1

0

I thought you could use FlyoutBehavior property. There are three values for FlyoutBehavior : Disabled, Flyout and Locked. So we could disable the flyout if we set FlyoutBehavior to Disabled.

When doing the calculation, set the this.FlyoutBehavior = FlyoutBehavior.Disabled and when the calculation is finished, set this.FlyoutBehavior = FlyoutBehavior.Flyout. You could use MessagingCenter to notify.

In the FlyoutPage, create a subscriber to receive message

public AppShell()
{
    InitializeComponent();
    ...

    MessagingCenter.Subscribe<CalculationPage, string>(this, "Hi", (sender, args) =>
    {
        if (args == "Enable")
        {
            this.FlyoutBehavior = FlyoutBehavior.Flyout;
        }
        else if (args == "Disable")
        {
            this.FlyoutBehavior = FlyoutBehavior.Disabled;
        }
    });


}

And in the calculation page, when you start calculation:

MessagingCenter.Send<CalculationPage,string>(this, "Hi","Disable");
        

when calculation is finished, set it back:

MessagingCenter.Send<CalculationPage, string>(this, "Hi", "Enable");

For more information about MessagingCenter, you could refer to Publish and subscribe to messages

Hope my answer could help you.

Liqun Shen-MSFT
  • 3,490
  • 2
  • 3
  • 11
  • Unfortunately, I do not have a Flyout page. I build my flyout menu in the AppShell with some ShellContents and the page displayed is a ContentPage. In the ContentPage i do not have the IsGestureEnabled property :( – nicetomitja Nov 16 '22 at 06:46
  • Hi, I have updated my answer. To use `this.FlyoutBehavior = FlyoutBehavior.Disabled`, we disable the flyout menu. – Liqun Shen-MSFT Nov 16 '22 at 13:04
  • This also not worked for me. But in the ContentPage itself I can use Shell.Current.FlyoutBehavior = FlyoutBehavior.Disabled; Thank you! – nicetomitja Nov 17 '22 at 15:04