protected override void OnNavigatedFrom(NavigationEventArgs e)
{
try
{
#if WINDOWS_PHONE_APP
HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
#elif WINDOWS_UWP
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
}
if (CanSubscribeToBackRequest)
{
UnsubscribeFromBackRequestedEvent();
}
#endif
if (GoBackViewModel != null)
{
GoBackViewModel.ClearPreviousViews -= ClearViews;
}
var satvm = StatesAndTransitionsViewModel;
if (satvm != null)
{
satvm.StateChanged -= ViewModelStateChanged;
satvm.RunStoryboard -= RunStoryboard;
satvm.StopStoryboard -= StopStoryboard;
//EventsWired = false;
}
base.OnNavigatedFrom(e);
#if WINDOWS_UWP
if (EnablePageCaching)
{
if (e.NavigationMode == NavigationMode.Back)
{
NavigationCacheMode = NavigationCacheMode.Disabled;
}
}
#endif
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
}