windows-phone-7.1back-stack

How Can I remove backstack till the required pagename in Wp7.1


I want to remove pages from backstack till a particular page say "C" has reached when I am on some other page say "F". Is Its posiible to remove backstack upon pagename?

Thanks and Regards, Kanaya


Solution

  • You can easily traverse the backstack and check the page names and remove items like this:

            while (NavigationService.CanGoBack)
            {
                if (NavigationService.BackStack.First().Source.OriginalString == "/C.xaml")
                {
                    break;
                }
                NavigationService.RemoveBackEntry();
            }