0
votes

I'm kind new on Xamarin Forms and I'm having trouble to figure out what the problem is with the Navigation between pages. I already read a bunch of articles from Xamarin docs, e.g. Xamarin Navigation Docs and people having similar problems but I haven't figure out yet.

So, I'm having the following error: "PushAsync is not supported globally on iOS, please use a NavigationPage."

I have a login page and if login is successful then I navigate to a Menu page. I have a button in that page that would lead to another page but when it is clicked the error is raised.

Code:

On App.cs I have defined:

MainPage = new MainPage();

This "MainPage" is the login page. After login is successful the following code is executed:

App.Current.MainPage = new MenuPage();

The "MenuPage" is shown. When I click a button it should navigate to another page:

async void Bt_Photo_Clicked(System.Object sender, System.EventArgs e)
    {
        await Navigation.PushAsync(new PhotoPage());
    }

I tried several variations but no success, like for instance not calling async the new "PhotoPage" but ya, not working also. Can anyone explain what am I doing wrong?

Thanks in advance

P.S. All pages are contentPages.

2

2 Answers

2
votes

if you want to use Navigation, you need to include you page within a NavigationPage

App.Current.MainPage = new NavigationPage(new MenuPage());
0
votes

This is because you don't initialised navigation page

MainPage =new NavigationPage( new MainPage());

You didn't created navigation page, that's why you can't navigate to next page