How do I clear the Navigation stack?

Ibrahim picture Ibrahim · Feb 12, 2015 · Viewed 27.5k times · Source

I have problem for Navigation in my app. I use xamarin.forms how can clean my navigation stack. No use Pop and push. Can I see my full navigation stack ?

Answer

User1 picture User1 · Feb 12, 2015

In the latest version of Xamarin.Forms you can see your navigation stack using

Navigation.NavigationStack

therefore you could use a

var existingPages = Navigation.NavigationStack.ToList();
foreach(var page in existingPages)
{
    Navigation.RemovePage(page);
}

This code would have to go into your code behind of a Navigation Page or something that implements INavigation.

More information Xamarin.Forms.INavigation Members