Igor Henriques
Igor Henriques

Reputation: 307

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

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.

Upvotes: 1

Views: 5210

Answers (1)

Sayo Komolafe
Sayo Komolafe

Reputation: 998

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

Upvotes: 5

Related Questions