Search code examples
c#.netxamarinxamarin.formsxamarin.ios

Xamarin.Forms.Navigation.PopAsync() Does Not Pop Page


In Xamarin.Forms, when we use Navigation.PopAsync(), the page does not pop in iOS.

After PopAsync() the same page remains.


Solution

  • Call the Proper Pop Method

    If you pushed the page onto the Navigation Stack using Navigation.PushAsync(), use Navigation.PopAsync() to pop the page off of the Navigation Stack.

    If you pushed the page on to the Navigation Stack using Navigation.PushModalAsync(), use Navigation.PopModalAsync() to pop the page off of the Navigation Stack.

    Use BeginInvokeOnMainThread

    All UI updates must be done on the main thread. To ensure that this request is happening on the main thread, use BeginInvokeOnMainThread:

    Device.BeginInvokeOnMainThread(async () => await Navigation.PopAsync());
    

    or

    Device.BeginInvokeOnMainThread(async () => await Navigation.PopModalAsync());