Should I always use Navigation.Popasync()?

Asked

Viewed 649 times

2

I am starting learning using Xamarin Forms. In my case, I am doing some tests with an application for Android.

Running a parallel with Windows Phone, when I navigate from a page A to page B, and then press the Back button on the WP, it removes the page from the stack correctly.

On android there is this concept of Push and Pop on the pages. My question is: should I always use the Navigation.Popasync() method? Or do I just use the device’s own navigation buttons to turn the pages? In case I have to use Navigation.Popasync(), I should put it in the Ondisappearing event()?

Hugs.

1 answer

4


It depends. In the Android and UWP we have physical buttons that can perform the navigation and this navigation pops the pages. No iOS we don’t have that button, so if you’re not in a container NavigationPage, the navigation arrow at the top left of the screen will not appear, and you should use the PopAsync.

About events fired at the moment a Popasync is invoked (Taken from the documentation itself):

When the PopAsync method is Invoked, the following Events occur:

  • The page Calling Popasync has its Ondisappearing override Invoked.
  • The page being returned to has its Onappearing override Invoked.
  • The Popasync task Returns.

The documentation is quite complete, worth taking a look: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/hierarchical/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.