WinRT - 如何从导航历史记录中忽略或删除页面

WinRT - How to ignore or delete page from navigation history(WinRT - 如何从导航历史记录中忽略或删除页面)
本文介绍了WinRT - 如何从导航历史记录中忽略或删除页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WinRT metro (c# - xaml) 应用程序有以下情况:

I have following situation in my WinRT metro (c# - xaml) application :

用户启动应用程序但他或她没有登录.在菜单栏中,我有将他们导航到购物车的按钮.值得一提的是,无论登录/退出状态如何,他们都可以点击它.

User launch the application and he or she is not logged in. In the menu bar I have button which navigates them to Shopping cart. It's important to mention that they can click on it regardless of logged in/out status.

所以我有这个:

Home Page - > Login Page - > Shopping Cart

一切都很好,但是当我尝试在我的 购物车 页面上按 BACK 按钮时,我被导航回 Login 页面,这是有道理的,因为页面是在我的导航历史中.但我不希望这样,我想将用户返回到主页并跳过登录页面.

And everything works great, but when I try press BACK button on my Shopping Cart page I'm navigated back to Login Page, which make sense, because page is in my navigation history. But I don't want that, I want to return user to Home Page and skip login page.

我的问题是如何做到这一点,以及如何在 WinRT 上操作框架导航堆栈.我尝试了两次返回,但没有成功.

My question is how to do that, and how to manipulate Frame Navigation Stack on WinRT. I tried with going Back twice, but with no luck.

顺便说一句,我的页面是LayoutAwarePage"页面,我正在使用与此类似的 NavigationServicehttp://dotnetbyexample.blogspot.com/2012/06/navigationservice-for-winrt.html.

Btw, my page is "LayoutAwarePage" page and I'm using NavigationService similar to this http://dotnetbyexample.blogspot.com/2012/06/navigationservice-for-winrt.html.

推荐答案

你可以用不同的方式来处理它.您可以使后退按钮多次导航,直到它到达主页或跳过登录页面.您还可以使登录页面显示在导航 Frame 之外 - 在弹出窗口或应用程序的不同层中.

You can approach it in different ways. You can make it so the back button navigates back multiple times until it reaches the home page or skips through the log in page. You could also make the log in page something that shows up outside of the navigation Frame - either on a popup or in a different layer in the application.

*更新

在 8.1 中,平台引入了 Frame 上的 "noreferrer">BackStackForwardStack 属性,您可以对其进行操作.

In 8.1 the platform introduced the BackStack and ForwardStack properties on the Frame which you can manipulate.

这篇关于WinRT - 如何从导航历史记录中忽略或删除页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)