How do I clear the Navigation stack?
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
This is a function I made to empty the stack and navigate to a specified page. (The use case was the app was de-activated during use and I need to kick the user out)
public async Task PopAllTo(ViewModel vm)
{
if (vm == null) return;
Page page = PreparePage(vm); //replace 'page' with the page you want to reset to
if (page == null) return;
_navigation.InsertPageBefore(page, _navigation.NavigationStack.First());
await _navigation.PopToRootAsync();
}