Bug 51708 - [UWP] Page OnDisappearing not called
Summary: [UWP] Page OnDisappearing not called
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-01-23 15:22 UTC by Dániel Buga
Modified: 2017-06-20 20:08 UTC (History)
5 users (show)

Tags: uwp ondisappearing
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 INVALID

Description Dániel Buga 2017-01-23 15:22:22 UTC
When the application is exited using the device's back button, the page's OnDisappearing is not called.
Comment 1 Paul DiPietro [MSFT] 2017-02-28 22:41:41 UTC
I'm presently experiencing some oddities with deploying to device but I believe I recently checked this and noticed it was an issue, so I will set to assigned for now so it can be double checked and looked into further when things aren't acting up.
Comment 2 Edward Brey 2017-05-03 16:13:46 UTC
OnDisappearing is also not called when the user exits a UWP app.
Comment 3 Edward Brey 2017-05-03 17:05:47 UTC
To clarify, I'm referring to the case of clicking the Close button in the upper right of a windowed UWP app. OnDisappearing does not get called in this case.
Comment 4 Rui Marinho 2017-06-20 19:31:09 UTC
This a normal behavior as the app is being closed (going to background) same behavior is similar in all platforms. 

You should use OnSleep on the Application class for anything you need to do at that time.
Comment 5 Edward Brey 2017-06-20 20:08:58 UTC
At the very least, the documentation for OnDisappearing should state this behavior. What else should a developer expect except that OnDisappearing should be called when the app (and hence the page along with it)... well... umm... disappears?

The method description "When overridden, allows the application developer to customize behavior as the Page disappears." (https://developer.xamarin.com/api/member/Xamarin.Forms.Page.OnDisappearing/) makes it sound like the method does exactly what you'd expect. If you really don't want the framework to work that way, please document whatever the funky behavior is, so that we developers can anticipated it.

Even better would be to put the smarts in so that OnDisappearing is always called when a page disappears. Application.OnSleep is fine for application-level actions, but it lacks context for page-level actions. It also doesn't work well for actions that aren't affected by the reason the page is disappearing.