You are here

How to clear the back stack in Windows RT (Windows Store) apps

Once you have set Window.Current.Content to a Frame, save a copy of the navigation stack.

// After the main application frame is established, save its navigation state. 
var appFrame = Window.Current.Content = new Frame(); 
var emptyNavState = appFrame .GetNavigationState(); 
// Here we're pushing a page onto the stack. appFrame.NavigateTo(foo); 
// If we want to clear the stack, this won't work: 
// appFrame.GoBack(); 
// So instead we simply restore the navigation state to its empty state. 
appFrame.SetNavigationState(emptyNavState);
Tags: 

Add new comment

Simple Copyright Policy: If you want to reproduce anything on this site, get my permission first.