Reputation: 1175
How does Windows 8 manage a stack of Pages in a Frame?
And how can I clear the whole stack programmatically, as in I need to 'pop' all pages in a stack and return to first page where I started from (let's say Login Page)?
Upvotes: 0
Views: 2777
Reputation: 8852
best solution would be
while (this.Frame.CanGoBack)
{
this.Frame.GoBack();
}
Upvotes: 0
Reputation: 190
In the Common/LayoutAwarePage.cs there is the following GoHome() function (in addition to the GoBack() function used with the Click-event on the standard Back button):
// Use the navigation frame to return to the topmost page
if (this.Frame != null)
{
while (this.Frame.CanGoBack) this.Frame.GoBack();
}
Upvotes: 3
Reputation: 15006
Try implementing your own Frame class, something similar to this:
Then you could write a RemoveLastEntry method that basically does this:
void RemoveLastEntry()
{
if (_navigationStack.Count > 0)
{
_navigationStack.Pop();
}
}
and call this method a certain number of times.
Or you could call GoHome method which takes you back to the first screen (that would be clearing the whole stack except the first item).
I hope this'll take you in the right direction!
Upvotes: 0
Reputation: 50682
Have a look at the methods of the Frame class
In this article (a must read about navigation):
private void ResetPageCache()
{
var cacheSize = ((Frame) Parent).CacheSize;
((Frame) Parent).CacheSize = 0;
((Frame) Parent).CacheSize = cacheSize;
}
Upvotes: 3