How to PopAsync more than 1 page in Xamarin Forms Navigation?

前端 未结 5 1003
一生所求
一生所求 2021-02-07 04:27

In my app I\'m pushing pages using a NavigationPage and at some stage I want to go back to a previous page in the stack. This is my structure:

NavigationPag

5条回答
  •  醉梦人生
    2021-02-07 04:46

    If you have a count that you would like to pop, this works really well for me.

    
        for(i=1; i < size; i++)
        {
        if (Device.OS == TargetPlatform.Android)
            {
                Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]);
            }
            else
            {
                Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
            }
        }
        await Navigation.PopAsync();
    

提交回复
热议问题