How to PopAsync more than 1 page in Xamarin Forms Navigation?
If you have a count that you would like to pop, this works really well.
for (var counter = 1; counter < BackCount; counter++)
{
Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
}
await Navigation.PopAsync();
I was trying to do the same thing - what I've wound up doing is a bit of a hack, but does work and keep the back button of page 2 going to page 1.
Basically,
var page3 = _navi.NavigationStack.FirstOrDefault(p => p is Page3Type);
if(page3 != null)
{
_navi.RemovePage(page3);
}
await navi.PopAsync();
What this does is first, if present, remove page3. Now that that's gone, it pops, and you're back at page 2.