0
votes

I have tried this both using Prism as well as with Xamarin Forms inbuilt Navigation.

I have PageA and PageB (both using MVVM). During my app startup (App.xaml.cs), I Navigate to PageA. During PageA initialization I encounter an error and want to send the App to PageB, so within PageA I perform navigation to PageB.

Once I reach PageB, I have the back arrow displayed to navigate back, but clicking on it never sends me back to the previous page (PageA). How do I achieve this ?

Thanks in advance.

Edit: Added code below (Prism based)

App.Xaml.cs:

public App(IPlatformInitializer initializer = null):base(initializer)
    {
        NavigationService.NavigateAsync("NavigationPage/PageA");
    }

PageAVM:

public PageAVM(INavigationService navigationService)
    {
        _navigationService = navigationService;
    }

public async void OnAppearing()
    {
        // Perform some actions and if there is an error navigate to PageB
        await _navigationService.NavigateAsync("PageB");            
    }

Expectation is that I am navigated to PageB, with the back button available and able to press it to move back to PageA.

In actuality, pressing the back button or the hardware back button does not take me back to PageA.

If I move the navigation to within the constructor of PageA, I am able to navigate back, but any toolbar items on PageA get retained on PageB.

1
Please show the relevant code.Jason
Updated with code.Sirpingalot
If you can reproduce it as simply as you have laid out please open an issueDan Siegel

1 Answers

0
votes

You need to use the namespace to change the root.

>

await NavigationService.NavigateAsync("{Namespace}:///PageB");