Four page xamarin forms, pages 1>2>3>4 with page 4 as the last page to navigate to
After Navigating to page 4, i want to go back to page 2, skipping page 3
I tried putting a button on page 4 that navigates back to page 2
But after clicking the Back button, it brings me back to page 4 instead of page 1
im stuck
Now that you have 4 pages in your navigation stack 1>2>3>4 and now you want to go from Page 4 to Page 2. You have to remove Page 3, You can not navigate to Page 2 Because then the stack will become this 1>2>3>4>2. You want the stack to be like 1>2>4 .So when you pop from Page 4 it goes to Page 2.
Code to remove Page 3 from stack
var page = Navigation.NavigationStack[Navigation.NavigationStack.Count - 2];
// you have the second last page now in page variable
Navigation.RemovePage(page);
after this stack will become 1>2>4
Now, you can write following in page 4
await Navigation.PopAsync();
And you'll come to page 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With