Forum Xamarin.Forms

Issue with navigation

I'm having page Nav issues .
In my view model I have await PageService.PushAsync(new NavigationPage(new AccountDetailsPage()));

PageService is an Interface for testing which ends up being this:
public async Task PushAsync(Page page)
{
await Application.Current.MainPage.Navigation.PushAsync(page);
}

I am getting this error is: PushAsync is not supported globally on Android, please use a NavigationPage.

This only works when I change it to PushModalAsync. Any Advice

Tagged:

Best Answer

  • GreekTreatGreekTreat ✭✭
    Accepted Answer

    Thanks I figure this out I completely screwed up the code. I reworked it to make it work now.
    I created this function instead
    private async Task PushAsync(Page nextPage)
    {
    var mainPage = App.Current.MainPage as MasterDetailPage;
    await mainPage.Detail.Navigation.PushAsync(nextPage).ConfigureAwait(false);
    mainPage.IsPresented = false;
    }

Answers

  • nnovalbosnnovalbos Member ✭✭

    I think is not allowed put navigation page inside another navigation page.

    When you use PushModalAsync, you create another stack of views and this is allowed

  • GreekTreatGreekTreat Member ✭✭
    Accepted Answer

    Thanks I figure this out I completely screwed up the code. I reworked it to make it work now.
    I created this function instead
    private async Task PushAsync(Page nextPage)
    {
    var mainPage = App.Current.MainPage as MasterDetailPage;
    await mainPage.Detail.Navigation.PushAsync(nextPage).ConfigureAwait(false);
    mainPage.IsPresented = false;
    }

Sign In or Register to comment.