Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prism Xamarin GetCurrentPage is it possible

Is it possible to get what the current page in the navigation stack is when using Prism for xamarin?

I have noticed there is the

 PageUtilities.GetCurrentPage(mainPage).

What is the usage of the above?

I was looking for something like navigationService.GetCurrentPage()

many thanks

like image 407
developer9969 Avatar asked Feb 01 '26 05:02

developer9969


1 Answers

Looking at the code for PageUtilities it looks like this method will do what you want, i.e. return the current page in the navigation stack. It looks like it handles the scenario where the current page is a MasterDetailPage, TabbedPage, CarouselPage or NavigationPage, and returns the correct page. I've tested it a little in my own app and it works as expected.

You can pass Application.Current.MainPage as the parameter to the method, like so:

var currentPage = PageUtilities.GetCurrentPage(Application.Current.MainPage);
like image 84
David Conlisk Avatar answered Feb 02 '26 21:02

David Conlisk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!