1

I'm doing a Master Detail Page as a menu and I'm getting this error:

PushAsync is not supported globally on Android, please use a NavigationPage.

When I try to instantiate another page. I believe my code already creates a navigation page when instantiate the page, but I'm not sure. Can someone help me?

App.xaml.cs:

public partial class App : Application
{
    static public MasterDetailPage MasterDetail { get; set; }

    public async static Task NavigateMasterDetail(Page page)
    {
        App.MasterDetail.IsPresented = false;
        await App.MasterDetail.Navigation.PushAsync(page);
    }


    public App ()
    {
        InitializeComponent();

        MainPage = new selectPage();
    }

Page that carry the menu, selectPage:

public partial class selectPage : MasterDetailPage
{
    public selectPage()
    {
        InitializeComponent();

        this.Master = new Master();
        this.Detail = new NavigationPage(new Detail());

        App.MasterDetail = this;
    }
}

Master.xaml.cs:

public Master ()
{
    InitializeComponent ();

    toDivPage.Clicked += async (sender, e) =>
    {
        await App.NavigateMasterDetail(new MainPage());
    };

    toBiqPage.Clicked += async (sender, e) =>
    {
        await App.NavigateMasterDetail(new MainPage());
    };
}

Detail.xaml.cs is empty.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Igor Henriques
  • 187
  • 1
  • 13
  • Actually, I'm new on Xamarin and I don't know exactly what I did wrong, so I need help to figure out what I did so this error appear... – Igor Henriques Jun 08 '18 at 22:25
  • Does https://stackoverflow.com/questions/24621814/pushasync-is-not-supported-globally-on-android-please-use-a-navigationpage-xa or https://forums.xamarin.com/discussion/18590/how-to-work-around-pushasync-is-not-supported-globally-on-android or https://stackoverflow.com/questions/48070606/system-invalidoperationexception-pushasync-is-not-supported-globally-on-android help? – mjwills Jun 08 '18 at 22:35
  • It doesn't... Already accessed these links before posting :/ Actually, I was following this https://www.youtube.com/watch?v=UBqdI77_p-M tutorial and for him work perfectly and mine didn't – Igor Henriques Jun 08 '18 at 22:37

1 Answers1

5

I believe you have to use NavigationPage in your App.xaml.cs. In your App.xaml.cs make sure your constructor or App method looks like this

public App ()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new selectPage());
    }

I hope this helps

Sayo Babalola
  • 990
  • 14
  • 25