PushModalAsync followed by PushAsync crashes.

Hello everybody,

First of all, I just want to let you know that I am an IT student that just started to use xamarin and I already love it.

However, while i was following this tutorial (https://www.syntaxismyui.com/xamarin-forms-common-questions/xamarin-forms-switching-pages/), I noticed that if i use PushModalAsync(), the page shows as intended, but if on this new page I try to use PushAsync(), the app crashes instantly.

This happens on both Android and iOS.

My question is:

  • Are we supposed to be able to do so ? (That means i made a mistake)
  • If not, why ? (Any explanation is welcomed)

Thank you all in advance for your help and have a nice day !

Answers

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭

    That's a normal behavior. PushModalAsync will push the page as Modal, so you can't push another page until you call PopModalAsync to close the modal page. It's the same (or try to mimic it at least) as a modal window on desktop OSes (Windows, OSX...)

    Here an explanation of modal windows https://www.mjtnet.com/blog/2009/01/27/modal-vs-non-modal-windows-not-jazz/

  • Hello Nad,

    Thank you for the quick reply, I'll have a look at your link ASAP.

    Have a great day.

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    Do you push a NavigationPage in your PushModalAsync?

    You should do something like this Navigation.PushModalAsync(new NavigationPage(new MyModalPage));

    Then in your MyModalPage you should be able to use Navigation.PushAsync(new MyOtherPage());

    I haven't tested it right now, but im pretty sure I've had it working earlier.

Sign In or Register to comment.