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.
So I have this :
Home Page - > Login Page - > Shopping Cart
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.
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.
Btw, my page is "LayoutAwarePage" page and I'm using NavigationService similar to this http://dotnetbyexample.blogspot.com/2012/06/navigationservice-for-winrt.html.
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.*Update
In 8.1 the platform introduced the
BackStack
andForwardStack
properties on theFrame
which you can manipulate.You can call
GoHome()
on theBack
button event, that'll take you toHomePage
or first page of the application.I know it's old, but since Google found this page for me, maybe someone else will find this page too.
The answer, while a valid work-around, does not answer the question.
You can use this on the login page, removing it from the back stack.
When loading the page use
I wrote my own history tracking navigation service. You can find it here.
In case I move file or remove it, here's current version:
To pop from stack:
To Navigate to the Main Menu touching the back button:
To keep the user in the Main Menu even if they touch the back button: