0

Is there anyway to know in the OnNavigatedFrom if the App is navigating from this page because it is being suspended? I have event handlers that update the UI, that I dont want them unsubscribed from if I am just suspending the App

MattyMerrix
  • 10,793
  • 5
  • 22
  • 32

1 Answers1

0

Thanks to @Romasz and his answer to my comment I was able to figure out you can use this. Which works great!

protected override void OnNavigationFromPage(System.Windows.Navigation.NavigationEventArgs e)
{
    if (e.Uri.ToString() != "app://external/") 
    {
        //App being suspended.
    }
    else
    { 
        UnSubscribeFromEvents(); 
    }
}

As you see the NavigationEventArgs Uri property is set to "app://external/" when you are being suspended, any other time it contains a full uri string of the page you are going too! This is just what I was looking for.

You can see the original post here.

Detecting deactivation and app close in Windows Phone 8.1 XAML

Community
  • 1
  • 1
MattyMerrix
  • 10,793
  • 5
  • 22
  • 32