Navigation from modal not working in .net maui

Viewed 47

How do you navigate from a modal popup?

I've opened a modal page using await NavigationService.PushModalAsync() which I'm using as a login page. With a successful login, I'm trying to close the modal and navigate to an account page.

await NavigationService.PopModalAsync();

await NavigationService.PushAsync();

The modal closes, but it will not show the page specified in the PushAsync Method. Both lines of code run, no errors thrown. The page the pushasync() goes to, displays fine if the login modal window is skipped.

The above code is in a [RelayCommand] method using community toolkit mvvm

What do I need to do to get the above to work?

1 Answers

enter image description here

Unfortunately your needs cannot be achieved. As mentioned in the figure above, the login page you created is a modal page, therefore it can navigate only to another modal page. When you call PopModalAsync, the login page pops up from ModalStack directly, meanwhile the (moldeless) page at the top of the NavigationStack will appear. And you call PushAsync to navigate to the account page in modal page, it doesn't work.

Related