On Navigated From(NavigationEventArgs) Method
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
protected: virtual void OnNavigatedFrom(NavigationEventArgs ^ e) = OnNavigatedFrom;
void OnNavigatedFrom(NavigationEventArgs const& e);
protected virtual void OnNavigatedFrom(NavigationEventArgs e);
Protected Overridable Sub OnNavigatedFrom (e As NavigationEventArgs)
Event data that can be examined by overriding code. The event data is representative of the navigation that has unloaded the current Page.
OnNavigatedFrom is invoked by default when you navigate between pages in your app. You can override this method and get info about the navigation from the NavigationEventArgs, and take any action required by your app. However, you should avoid changing the state of the page by unregistering event handlers or doing other cleanup, especially in apps that call Frame.GetNavigationState on suspend.
In addition to being invoked when navigating between pages, the OnNavigatedFrom method is invoked when the app is suspended if Frame.GetNavigationState is called in the Application.Suspending event handler.
While it seems natural to use OnNavigatedFrom to unregister event handlers that were registered in OnNavigatedTo, this can lead to problems if your app saves its state on suspend. Saving state on suspend typically involves calling Frame.GetNavigationState, which then calls Page.OnNavigatedFrom on the current page, which signals the page to persist/serialize any state it retains on back navigation or rehydration. If the app is suspended and then resumed (without a termination and relaunch), any event handlers unregistered in OnNavigatedFrom won't be re-registered because Page.OnNavigatedTo isn't called on resume.