Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pop then immediately push xamarin pages

my current navigation stack has two pages. First is page A, second is Page B. When I click my button, It'll add a new page to the navigation stack, Page C.

May I ask how do I display Page C and remove Page B, or remove page B and display page C.

I've tried the following

await Navigation.PopAsync()
await Navigation.PushAsync(new CustomPage())

The issue i'm having with this is that the page pops successfully, but the new page isn't visible. I immediately see page A. May I ask how do I pop the current page and immediately show another.

like image 213
Phoenix Avatar asked Mar 06 '19 22:03

Phoenix


1 Answers

Instead of popping the page and then trying to push the new page. I would push your new page then remove the previous page from the NavigationStack.

var previousPage = Navigation.NavigationStack.LastOrDefault();
await Navigation.PushAsync(new CustomPage());
Navigation.RemovePage(previousPage);
like image 72
Nick Peppers Avatar answered Nov 15 '22 15:11

Nick Peppers