Remove All Navigation Back in Windows Phone


Before using below function, you need to include Microsoft.Phone.Controls nampespace in your project.
 
using Microsoft.Phone.Controls;

 
public static void RemoveAllNavigationBack()
{
     if (!((PhoneApplicationFrame)Application.Current.RootVisual).BackStack.Any()) return;
     var length = ((PhoneApplicationFrame)Application.Current.RootVisual).BackStack.Count();
     var i = 0;
     while (i < length)
     {
         ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
         i++;
     }
}

Or, you can remove Navigation Backstack by your choice.
 
public static void RemoveNavigationBack(int count)
{
     for (var i = 0; i < count; i++)
     {
         ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
     }
}

 
I hope you find this post helpful, Thanks for reading.