0
当使用Prism for xamarin时,是否可以得到导航堆栈中的当前页面?Prism Xamarin GetCurrentPage是可能的
我已经注意到存在
PageUtilities.GetCurrentPage(mainPage).
什么是上述的使用情况如何?
我一直在寻找类似navigationService.GetCurrentPage()
千恩万谢
当使用Prism for xamarin时,是否可以得到导航堆栈中的当前页面?Prism Xamarin GetCurrentPage是可能的
我已经注意到存在
PageUtilities.GetCurrentPage(mainPage).
什么是上述的使用情况如何?
我一直在寻找类似navigationService.GetCurrentPage()
千恩万谢
看着the code for PageUtilities它看起来像这个方法会做你想做的,即在导航堆栈返回当前页面。它看起来像处理当前页面是MasterDetailPage,TabbedPage,CarouselPage或NavigationPage的场景,并返回正确的页面。我已经在我自己的应用程序中测试了一下,它按预期工作。
您可以通过Application.Current.MainPage
作为参数传递给方法,就像这样:
var currentPage = PageUtilities.GetCurrentPage(Application.Current.MainPage);
你能告诉我你如何使用您的视图模型里面的方法的小片段?因此,假设你有一个应用程序,3页和3 vms- VM1-VM2-VM3等。在vm3你想找出当前页面你做什么? – developer9969
@ developer9969看到我编辑的答案,只需调用方法,无论你需要当前页面,传递Application.Current.MainPage作为参数。 –
感谢您的答复。已尝试但MainPage始终为null。您可以在NavigatedTo方法中调用此方法吗? – developer9969