Fast App Resume crashing on WP8.1 when not attached to debugger

后端 未结 1 1156
忘掉有多难
忘掉有多难 2021-01-14 18:01

I am developing a WP8.1 app using MVVM Light. Fast app resume is activated by default which is great as I want to include it in the app.

It works as expected when th

1条回答
  •  悲&欢浪女
    2021-01-14 18:28

    In your App.xaml.cs, add this code:

    private bool reset;
    
    private void InitializePhoneApplication()
    {
        if (phoneApplicationInitialized)
         return;
    
        RootFrame.Navigating += RootFrame_Navigating;
    
        RootFrame.Navigated += RootFrame_Navigated;
    } 
    
    void RootFrame_Navigated(object sender, NavigationEventArgs e)
    {
        reset = (e.NavigationMode == NavigationMode.Reset);
    }
    
    void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
    {
        if (reset && e.IsCancelable && e.Uri.OriginalString == "/XXXX.xaml")
        {
            e.Cancel = true;
            reset = false;
        }
    }
    

    And in your WMAppManifest.xml, add this code:

    
      
    
    

    0 讨论(0)
提交回复
热议问题