問題描述
我的 WinRT metro (c# - xaml) 應用程序有以下情況:
I have following situation in my WinRT metro (c# - xaml) application :
用戶啟動應用程序但他或她沒有登錄.在菜單欄中,我有將他們導航到購物車的按鈕.值得一提的是,無論登錄/退出狀態(tài)如何,他們都可以點擊它.
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">BackStack
和 ForwardStack
屬性,您可以對其進行操作.
In 8.1 the platform introduced the BackStack
and ForwardStack
properties on the Frame
which you can manipulate.
這篇關于WinRT - 如何從導航歷史記錄中忽略或刪除頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!