Hi,
I have a ContentPage which i show as PushModalAsync but in one case I am showing it as MainPage
How can I check how the page was opened? was it opened as PushModalAsync or MainPage?
Thanks,
Jassim
Hi,
I have a ContentPage which i show as PushModalAsync but in one case I am showing it as MainPage
How can I check how the page was opened? was it opened as PushModalAsync or MainPage?
Thanks,
Jassim
Hello,
Welcome to our Microsoft Q&A platform!
If you open page as PushModalAsync. You can use var CurrentPage = Navigation.ModalStack.ToList<Page>().Last<Page>(); code to get the current display page.
If you want to get all of opened page by PushModalAsync. Please use following code.
List<Page> pages= Navigation.ModalStack.ToList<Page>();
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi,
I tried this in my PushModalAsync opened page:
var CurrentPage = Navigation.ModalStack.ToList<Page>().Last<Page>();
App.Current.MainPage.DisplayAlert("CurrentPage", CurrentPage.ToString(), "");
but getting:
System.ArgumentNullException: Value cannot be null.
Parameter name: cancel
Please add a string to third parameter like following code. Do not leave it to empty.
App.Current.MainPage.DisplayAlert("CurrentPage", CurrentPage.ToString(), "Ok");

10 people are following this question.