如何在 Windows Universal 中完成当前页面 [英] How to finish current page in Windows Universal

查看:25
本文介绍了如何在 Windows Universal 中完成当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 UWP 开发中关闭当前活动页面?

How can I close the current active Page in UWP development?

我想开始一个新页面并关闭当前页面,因此用户无法返回该页面.UWP 中有没有类似于 Android 的方法finish()"的方法?

I want to start a new Page and close the current one, so the user cannot go back to that page. Is there any method in UWP similar to Android's method "finish()"?

推荐答案

我认为您应该能够通过在导航到新页面后从后堆栈中删除最后一页来实现此目的.新页面的 OnNavigatedTo 中的示例代码:

I think you should be able to do this by removing last page from back stack after navigating to a new one. Sample code in OnNavigatedTo of a new page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    this.Frame.BackStack.RemoveAt(this.Frame.BackStack.Count - 1);
}

这应该可以防止用户返回到最后一页.当然,如果需要,您可以通过多种方式修改后台堆栈.

This should prevent user from going back to last page. Of course you can modifay the back stack in many ways if you need.

这篇关于如何在 Windows Universal 中完成当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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