xamarin.formsmauiflyoutmaui-shell

Maui Shell Flyout IsPresentedChanged event


Xamarin forms to Maui migration question...

The FlyoutPage in XF has the IsPresentedChanged event that fires when the Flyout menu is displayed/hidden.

Is there an equivalent for Maui Shell Flyout? I can't find anything in the docs.

As a supplement I have a ContentView set as the Shell.FlyoutContent and I can accomplish my requirement (amend a property on the ContentView when the Flyout menu becomes visible) via an OnAppearing event on the ContentView.

Thanks in advance.


Solution

  • The Shell doesn't have a such event. But you can detect the Shell.FlyoutIsPresented Property changed by your custom event.

      public AppShell()
      {
          InitializeComponent();
          PropertyChanged += Changed;
      }   
    
      private void Changed(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
      {
          if(e.PropertyName == "FlyoutIsPresented")
          {
              if(FlyoutIsPresented)
              {
    
              }else
              {
              }
          }
      }