When navigating away from any page where I want the user to confirm that it's OK to leave I set the Cancel property of the args parameter to true and then show a MessageDialog so that the user can confirm or cancel the navigation. The problem is that the navigation completes before the user can confirm or cancel.
However, if I put the same code in the Page.OnNavigatingFrom override, it works correctly.
Here is a simple Template 10 project showing the issue:
NavigationIssue.zip
To illustrate the issue press the Submit button on the MainPage then hit the back button. The page has already navigated back to the MainPage by the time the MessageDialog pops up.
Repeat but check the CheckBox on the DetailsPage, hit the back button or the Home button on the menu and it was correctly. In this case it is using the code in the code behind file.
Yes, this is true.
I believe this is related to #1237 & #1149 . The future will be IConfirmNavigation as in #1261 :
Moving to Prism's IConfirmNavigation is the current plan
I think we have to stay with the workaround until T10 2.0 is released. Am I right @JerryNixon ?
What worked for me, based on @elstringo 's workaround:
In the OnNavigatingFromAsync cancel navigation with args.Cancel = true and call an async method to show dialog and wait for user's option, passing NavigatingEventArgs, that now has TargetPageType & TargetPageParameter.
Working on this right now.
Resolved in 1.1.13 (preview)
Most helpful comment
Resolved in 1.1.13 (preview)