Go to page and clear the stack [Xamarin Forms]

和自甴很熟 提交于 2021-02-08 02:05:26

问题


I have navigation stack like this:

Page1 -> Page2 -> Page3 -> Page4 -> Page5 -> Page6

And I want to Navigate TO Page2 FROM Page6 and clear rest of pages (Page3, Page4, Page5)

How can I do this?

Thanks in advance!


回答1:


When you want to navigate back a count of pages, you need to remove count pages from the navigation stack:

for (var i = 1; i < countPagesToRemove; i++)
{
    Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
}
await Navigation.PopAsync();


来源:https://stackoverflow.com/questions/50857611/go-to-page-and-clear-the-stack-xamarin-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!