July 26, 2012
Occurs when the application is being deactivated.
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
XMLNS for XAML: Not mapped to an xmlns.
This event is raised when the user navigates away from the application, by taking an action such as pressing the Start button or by invoking a Launcher or Chooser. An application is also deactivated when the lock screen engages. Handle this event by preserving the application’s transient application state into the State dictionary, which you can restore in the handler for the Activated event if the application is reactivated. It is not guaranteed that the application will be reactivated. Therefore, it is a good practice to also save persistent state, such as settings and user data, to isolated storage in the handler for this event. For more information about handling this event, see Execution Model for Windows Phone.
Applications are given 10 seconds to complete the handler. If the event handler has not been completed before this time span has elapsed, the application is terminated. It is recommended that applications aim for 2 seconds for completing the handler to provide a large buffer for unexpected delays. Applications should incrementally save data to isolated storage and to the State property while the application is running to reduce the amount of data storage that needs to be performed in the handler.
It is possible for your application to be activated without having been. For this reason, you should not destroy your application’s state in the handler for this event so that your application can resume without reestablishing state if it is activated without being tombstoned.
For more information about handling this event, see Execution Model for Windows Phone.