Navigation doesn't work when trying to GoBack to MainPage (Xamarin, Prism)

Alysson Amaral 156 Reputation points
2021-05-26T17:34:28.327+00:00

I have a HelpPage in my project that has a BackButton with this command on BaseViewModel:

DelegateCommand _goBack;
        public DelegateCommand GoBack => _goBack
            ?? (_goBack = new DelegateCommand(async () => await ExecuteGoBack()));

 private async Task ExecuteGoBack()
        {
            await NavigationService.GoBackAsync();
        }

When I am in my MainScreen and navigate to the HelpPage this BackButton doesn't work anymore. There is no error accused, it goes throught the method and just don't do anything. Also I have tried to put a button in the HelpPage to Navigate to mainScreen instead of going back, and doesn't work either. This the the way that I first navigate to my MainScreen:

Device.BeginInvokeOnMainThread(async () =>
            await NavigationService.NavigateAsync($"/{App.GetMainPageName()}"));

And in the App.cs:

public static string GetMainPageName()
        {
            Debug.WriteLine("App.cs: " + BluetoothModule.Instance.FirmwareVersion);
            switch (BluetoothModule.Instance.FirmwareVersion)
            {
                case FirmwareVersions.V1:
                    return nameof(MainPageV1);
                case FirmwareVersions.V2:
                    return nameof(MainPageV2V3);
                case FirmwareVersions.V3:
                    return nameof(MainScreen); 
                case FirmwareVersions.V4:
                    return nameof(MainPageV2V3);
                default:
                    return nameof(MainPageV2V3);
            }
        } 
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,380 questions
{count} votes

Accepted answer
  1. Alysson Amaral 156 Reputation points
    2021-05-27T16:14:36.36+00:00

    SOLVED

    The problem was when I was navigating to Help Menu I was doing a Absolute navigation. I just change to Relative and it worked.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.