1

I have the following minimal example of an app using Xamarin.Forms (version 1.2.3) and a MasterDetailPage (similar to: "Show "Back to Menu" Button in iOS NavigationBar with Xamarin.Forms"):

public static class App
{
    static MasterDetailPage MDPage;

    public static Page GetMainPage()
    {
        MDPage = new MasterDetailPage {
            Master = new ContentPage {
                Title = "Master",
                Icon = Device.OS == TargetPlatform.iOS ? "menu.png" : null,
                Content = new Button {
                    Text = "Open detail",
                    Command = new Command(o => {
                        MDPage.Detail = new NavigationPage(new ContentPage());
                        MDPage.IsPresented = false;
                    }),
                },
            },
            Detail = new NavigationPage(new ContentPage()),
        };
        MDPage.IsPresentedChanged += (sender, e) => Console.WriteLine(DateTime.Now + ": " + MDPage.IsPresented);
        return MDPage;
    }
}

(hosted on GitHub)

When opening or closing the MasterPage via button click on Android, the IsPresentedChanged event is triggered three times instead of once. According to the command line output the IsPresented property is either toggling as True-False-True or False-True-False, respectively.

Opening or closing using a swipe gesture or tapping on the DetailPage does work well. On iOS there is no problem at all.

Is there something I'm doing wrong? Or is there a simple workaround to get a reliable event?

Community
  • 1
  • 1
Falko
  • 17,076
  • 13
  • 60
  • 105

1 Answers1

0

Ok, with the current version 1.4.0 of Xamarin.Forms the issue seems to be fixed. Opening the slide-out menu yields exactly one "True", closing it yields "False" - just as expected.

Falko
  • 17,076
  • 13
  • 60
  • 105