I start my app showing a main page. From there the user goes through multiple pages until the app should go back to the main page. When I click the final button which should take me back nothing happens. So far I have read, NavigationPage is a must but I use them already.
At the moment I do this:
App.cs:
public App ()
{
StartPageView spv = new StartPageView (new StartPageViewModel());
NavigationPage np = new NavigationPage(spv);
MainPage = np;
NavigationUtils.Navigation = MainPage.Navigation;
}
In StartPageViewModel.cs:
var nextView = new NextView(new NextViewModel());
NavigationPage np = new NavigationPage(nextView);
Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
await NavigationUtils.Navigation.PushModalAsync(np);
}
);
In NextViewModel.cs:
this.BackCommand = new Command((nothing) =>
{
Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
await NavigationUtils.Navigation.PopToRootAsync();
}
);
},
(nothing) =>
{
return true;
});
When I call the BackCommand in NextViewModel nothing happens. I expect the app to go back to the StartPage.
What do I do wrong?