0
votes

I have an application with a Loginscreen, and a Mainpage

When I initialize my application I set the Navigation to "NavigationPage/LoginPage". When I log into the application I reset the stack with absolute navigation using the route "/NavigationPage/MainPage". All of my pages have a label bound to the current navigation Uri and when I reset the stack after logging in and navigate to the mainpage my Uri looks like this

/NavigationPage/LoginPage/MainPage?useModalNavigation=true

I've read that if you have duplicate pages on top of one another this can cause the navigation to become modal by default. But I'm resetting the stack and even resetting the NavigationPage. This doesn't cause any immediate issues, but I have found that in deeper parts of my application's navigation stack, some navigation isn't working and this seems to be the cause

Does anyone know why this is happening?

My code

App.xaml.cs

protected override async void OnInitialized()
{
     InitializeComponent();

     await NavigationService.NavigateAsync("NavigationPage/LoginPage");
}

LoginPageViewModel.cs

public ICommand LoginCommand { get; }
public LoginPageViewModel(INavigationService navigationService) : base(navigationService)
{
     LoginCommand = new Command(Login);
     NavUri = NavigationService.GetNavigationUriPath();
}

private async void Login()
{
     await NavigationService.NavigateAsync("/NavigationPage/MainPage");
}

MainPageViewModel.cs

public MainPageViewModel(INavigationService navigationService) : base(navigationService)
{
     Title = "Main Page";
     NavUri = NavigationService.GetNavigationUriPath(); // current URI on the mainpage is /NavigationPage/LoginPage/MainPage?useModalNavigation=true

     NavigateToPageACommand = new Command(NavigateToPageA);
}

I'm using; Xamarin Forms 4.6.0.726 Prism.Dryloc 7.2.0.1422

1
this sounds like a bug... can you provide a simple reproduction and open an issueDan Siegel

1 Answers

0
votes

Appears to be just a temporary value that occurs during OnNavigatingFrom. While the stack is being reset the Navigation appears to be Modal, however it is actually not. Discovered this by adding INavigationAware to my ViewModelBase and viewing the result of GetNavigationUriPath in the OnNavigatedTo and OnNavigatingFrom Methods.