如何在Xamarin Forms Navigation中弹出超过1页的页面? [英] How to PopAsync more than 1 page in Xamarin Forms Navigation?

查看:40
本文介绍了如何在Xamarin Forms Navigation中弹出超过1页的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用NavigationPage推送页面,并且在某个阶段我想返回堆栈中的上一页.这是我的结构:

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:

NavigationPage> Page1> Page2> Page3> Page4

NavigationPage > Page1 > Page2 > Page3 > Page4

如何直接从Page4 PopAsync回到Page2,而无需通过Page3?

How can I PopAsync back to Page2 directly from Page4 without going through Page3?

推荐答案

如果您有一个要弹出的计数,则效果很好.

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

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

这篇关于如何在Xamarin Forms Navigation中弹出超过1页的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆