0

I need a little advice on navigating the Xamarin Forms Shell. I'm trying to create a page with details. Navigation to the detail page works, but unfortunately the go back no longer works. See gif. Someone where I make a mistake would advise me. Thanks a lot.

My navigation code:

    GoToCommand = new RelayCommand(async () =>
    {
        await Shell.Current.Navigation.PushAsync(new DetailPage(this.TextEntry));

        //await Shell.Current.GoToAsync($"{nameof(DetailPage)}?detailtext={this.TextEntry}");

        //await Shell.Current.GoToAsync("DetailPage");
    });

    GoBackCommand = new RelayCommand(async () =>
    {
        await Shell.Current.Navigation.PopAsync();

        //await Shell.Current.GoToAsync("..");
    });

Source code: https://filebin.net/nhkar968g5hj7e9m/ShellNavigationTest.rar?t=ctq0geqi

enter image description here

  • You should use PushAsync instead of GotoAsync if your are willing to use PopAsync after – Cfun Mar 30 '21 at 23:33
  • Unfortunately, it doesn't work either. Going to the page works, not back. The back button does not respond. When I use Shell.Current.Navigation.PopAsync or GoToAsync ("..") the application crashes. –  Mar 30 '21 at 23:51
  • what is the error/exception that causing the crash ? – Cfun Mar 30 '21 at 23:53
  • https://i.imgur.com/hkSX1zo.png System.ArgumentException: 'Ambiguous routes matched for: //D_FAULT_FlyoutItem4/IMPL_HomePage/HomePage/D_FAULT_DetailPage8/D_FAULT_DetailPage9 matches found: //D_FAULT_FlyoutItem4/IMPL_HomePage/HomePage/D_FAULT_DetailPage8/D_FAULT_DetailPage9,//D_FAULT_FlyoutItem4/IMPL_HomePage/HomePage/D_FAULT_DetailPage8/D_FAULT_DetailPage9 Parameter name: uri' –  Mar 31 '21 at 00:03
  • I use XF - 5.0.0.2012 –  Mar 31 '21 at 00:11
  • It looks like the problem in XF itself https://github.com/xamarin/Xamarin.Forms/issues/13611 –  Mar 31 '21 at 00:24

1 Answers1

0

Regarding to the docs you should be able to use this here:

await Shell.Current.GoToAsync("..");
Jack
  • 66
  • 5