### Description
NavigationFrom is not called when navigating to a different Page related with menu item in HamburgerMenu (MasterDetail scenario).
All pages have ViewModels with INavigationAware implementation.
All ViewModels call OnNavigatedTo method when user navigates to them.
Create MasterDetail Page with MenuPage as a Master.
MenuPage has two buttons:
PageA is a default page (after openning the app, user landing on PageA)
Open MenuPage and hit btn2
PageAViewModel.OnNavigatedFrom - should be executed,
PageBViewModel.OnNavigatedTo - should be executed.
PageAViewModel.OnNavigatedFrom - is not executed,
PageBViewModel.OnNavigatedTo - is executed.
Please provide a sample that reproduces this issue.
Just open a HamburgerMenu Prism Sample and update to the latest version of Prism and Xamarin Forms. Override OnNavigatedFrom method in ViewAViewModel, ViewBViewModel and ViewCViewModel and put breakpoints.
When you switch between pages (A, B, C):
My case:
I wanted to use OnNavigatedFrom to save state of the working object on ViewA.
I have similar cases related with going app to the background or re-launch app when you hit Android notification panel (Foreground service) and those cases works.
Internal navigation doesn't worked as expected because of this bug.
Workaround is to use EventAggregator and publish an event when I hit another menu item but I don't want to complicate the app.
Updated sample in the attachment
Verified. Thanks for submitting this.
Super. Big thanks for this fix.
Can you tell me in which pre-release version it will be available ?
You can get it now in the latest CI builds on MyGet. We have some pretty large efforts going on right now regarding aligning Prism across platforms, so I don't have a timeframe for the next preview.
You surprised me with this MyGet. I used to not looking into this 'Packages source'. For most cases, nuget.org is enough. I would love to work with company where they have at least in 50% organized development process like you have for Prism. Congratulations.
Still does not work. Checked with 7.1.0.123-pre (it supposed to be fixed according to it's release notes). Checked on Android only. Here is the sample project.
https://github.com/IngweLand/App1
It works just fine. You aren't setting the useModalNavigation parameter to true.
Why should I set useModalNavigation parameter to true - I am not creating a modal page.
However, I think my mistake was different. I was changing pages with "absolute" style, like this:
initial set:
NavigationService.NavigateAsync($"{nameof(PrismMasterDetailPage1)}/{nameof(NavigationPage)}/{nameof(ViewA)}");
and to change a page i did:
NavigationService.NavigateAsync($"{nameof(PrismMasterDetailPage1)}/{nameof(NavigationPage)}/{nameof(ViewB)}");
However, when I changed second line to following, OnNavigationFrom started to be called:
NavigationService.NavigateAsync($"{nameof(NavigationPage)}/{nameof(ViewB)}");
Because you can't set the Detail of a MasterDetail to another MasterDetailPage. Therefore you must push it modally. Looks like you have it figured out.
I have similar problem with my app. When I'm on BasePage and I want to navigate from MasterDetailPage to some page (ViewA or ViewB), the OnNavigatedFrom method from BasePage not called. I tried to set useModalNavigation to true, but still doesn't work.
Prism: 7.0.0.396
Xamarin.Forms: 3.0.0.446417
So, I created test app. @brianlagunas , I will be grateful for your help.
https://github.com/aneti9862/XamarinForms
@SeRgI1982 I pulled down your HamburgerMenu.zip file and updated the Prism libraries to version 7.1.0.431 and tried it out on iOS. If I switch from ViewA to ViewB the OnNavigatedFrom method is called on the MainPage but not on ViewA. Is this how it should behave or should OnNavigatedFrom be called on ViewA?
@brianlagunas Could you confirm what Prism should be doing? When I navigate from ViewA to ViewB using an menu item on the MainPage, should the OnNavigatedFrom method be called on ViewA? Or on MainPage? Or both? Thanks!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.