3
votes

I have navigation stack like this:

Page1 -> Page2 -> Page3 -> Page4 -> Page5 -> Page6

And I want to Navigate TO Page2 FROM Page6 and clear rest of pages (Page3, Page4, Page5)

How can I do this?

Thanks in advance!

1
Which type of navigation do you have and what have you tried?EvZ
I have NavigationService where I use PushAsync and PopAsynctombolo
So you have a Hierarchical Navigation. What have you tried to achieve the required behaviour?EvZ
I have tried remove page after page from stack until i get Page2, but maybe there is better solution?tombolo
Unfortunately not. Not a built-in method that you could use. You will have to clean the navigation stack yourself.EvZ

1 Answers

3
votes

When you want to navigate back a count of pages, you need to remove count pages from the navigation stack:

for (var i = 1; i < countPagesToRemove; i++)
{
    Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
}
await Navigation.PopAsync();