Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to page and clear the stack [Xamarin Forms]

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!

like image 607
tombolo Avatar asked Oct 20 '25 07:10

tombolo


1 Answers

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();
like image 65
Dennis Schröer Avatar answered Oct 21 '25 22:10

Dennis Schröer