Bug 34570 - New protected virtual method desired: NavigationCompleted
Summary: New protected virtual method desired: NavigationCompleted
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.0
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-10-05 15:10 UTC by Charles Petzold
Modified: 2016-04-13 18:00 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Charles Petzold 2015-10-05 15:10:09 UTC
Currently, the OnAppearing and OnDisappearing methods are often used to perform jobs relating to the transfer of data between pages during page navigation. However, the order of calls to these two methods is not consistent. It varies by platform and whether modal or modeless navigation is occurring. On iOS, Android, and WP Silverlight, the PushAsync or PopAsync tasks complete after the calls to OnAppearing and OnDisappearing. On the Windows Runtime platform, this is not so. All these differences can be explored with the following program:

https://github.com/xamarin/xamarin-forms-book-preview-2/tree/master/Chapter24/SinglePageNavigation

That program uses Debug.WriteLine to log the various calls to OnAppearing and OnDisappearing, and the completion of the Push and Pop tasks.

In addition, there are anomalies on several platforms:

On iOS, OnDisappearing is called on the current page when the program is terminating.

On Android, PushModalAsync is not accompanied by a call to OnDisappearing, and PopModalAsync does not cause a corresponding call to OnAppearing in the page being returned to.

On Windows Phone Silverlight, the DatePicker, TimePicker, and Picker all cause calls to OnDisappearing when they are invoked, and OnAppearing when they return to the page from which they were invoked.

All these issues complicate the transfer of data between pages. A protected virtual method specifically indicating page navigation would be very useful. It could have the following signature:

protected virtual NavigationCompleted(Page pageFrom, Page pageTo)

The method would be called in both pages involved in the page navigation in a fixed order but with the same arguments. An override of the method in a particular page could determine if the page was being navigated to or from by comparing the values of the two arguments with its own instance.
Comment 1 Jason Smith [MSFT] 2016-04-13 18:00:05 UTC
Thank you for taking the time to submit this feature request. We like this idea and have added it to our internal feature tracking system.

Warm regards,
Xamarin Forms Team