How to remove particular page from modal stack?

前端 未结 4 2008
慢半拍i
慢半拍i 2021-01-29 07:42

I have four pages page 1-page 2-page 3-page 4.I use push modal async for navigating forward. When I tap button click in page 4 it is navigating to the page2. But tapping back bu

4条回答
  •  粉色の甜心
    2021-01-29 08:13

    Please use await Navigation.PopModalAsync() and read through this link to get info about ModalPages.

    EDIT:

    Haven't tested it, but could help to understand the approach:

    
    for (var i = Navigation.NavigationStack.Count - 1; i > 0; i--)
    {
        if (Navigation.NavigationStack[i] is Page2)
        {
            return;
        }
        await Navigation.PopModalAsync();
    }
    

提交回复
热议问题