<small id='rsZD0'></small><noframes id='rsZD0'>

    • <bdo id='rsZD0'></bdo><ul id='rsZD0'></ul>

    <i id='rsZD0'><tr id='rsZD0'><dt id='rsZD0'><q id='rsZD0'><span id='rsZD0'><b id='rsZD0'><form id='rsZD0'><ins id='rsZD0'></ins><ul id='rsZD0'></ul><sub id='rsZD0'></sub></form><legend id='rsZD0'></legend><bdo id='rsZD0'><pre id='rsZD0'><center id='rsZD0'></center></pre></bdo></b><th id='rsZD0'></th></span></q></dt></tr></i><div id='rsZD0'><tfoot id='rsZD0'></tfoot><dl id='rsZD0'><fieldset id='rsZD0'></fieldset></dl></div>
    <tfoot id='rsZD0'></tfoot>

        <legend id='rsZD0'><style id='rsZD0'><dir id='rsZD0'><q id='rsZD0'></q></dir></style></legend>

      1. Windows Phone 8.1 通用应用程序在从第二页返回时终

        时间:2023-08-28

              <small id='xUDKx'></small><noframes id='xUDKx'>

              <i id='xUDKx'><tr id='xUDKx'><dt id='xUDKx'><q id='xUDKx'><span id='xUDKx'><b id='xUDKx'><form id='xUDKx'><ins id='xUDKx'></ins><ul id='xUDKx'></ul><sub id='xUDKx'></sub></form><legend id='xUDKx'></legend><bdo id='xUDKx'><pre id='xUDKx'><center id='xUDKx'></center></pre></bdo></b><th id='xUDKx'></th></span></q></dt></tr></i><div id='xUDKx'><tfoot id='xUDKx'></tfoot><dl id='xUDKx'><fieldset id='xUDKx'></fieldset></dl></div>
              <tfoot id='xUDKx'></tfoot>

            1. <legend id='xUDKx'><style id='xUDKx'><dir id='xUDKx'><q id='xUDKx'></q></dir></style></legend>
              • <bdo id='xUDKx'></bdo><ul id='xUDKx'></ul>
                    <tbody id='xUDKx'></tbody>
                  本文介绍了Windows Phone 8.1 通用应用程序在从第二页返回时终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的 Windows Phone 8.1 通用应用中有 2 个页面.

                  I have 2 pages in my Windows Phone 8.1 Universal App.

                  我使用带有点击事件代码的按钮从 Page1.xaml 导航到 Page2.xaml:

                  I navigate from Page1.xaml to Page2.xaml by using a button with the click event code:

                  this.Frame.Navigate(typeof(Page2));
                  

                  当我在第 2 页上时,我使用硬件后退按钮,应用程序会毫无例外地关闭.它只是返回到开始屏幕.

                  When I am on Page2, and I use the hardware back button the app closes without an exception or anything. It just returns to the startscreen.

                  我已经在 第 2 页尝试了以下操作:

                  I already tried the following on Page 2:

                  public Page2()
                      {
                          this.InitializeComponent();
                          Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                      }
                  
                      void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
                      {
                          Frame.GoBack();
                      }
                  

                  据我所知,我没有清除后台堆栈.

                  As far as I know I do not clear the back stack.

                  发生了什么,我该如何解决?

                  What is going on, and how can I fix this?

                  亲切的问候,尼尔斯

                  推荐答案

                  这是 Windows Phone 8.1 的新功能.

                  This is new to Windows Phone 8.1.

                  如果您使用 VS2013 模板创建新的 Hub 通用应用程序,您会注意到 Common 文件夹中有一个名为 NavigationHelper 的类.

                  If you create a new Hub Universal App using a VS2013 template, you'll notice a class in Common folder called a NavigationHelper.

                  此 NavigationHelper 会提示您如何正确响应按下后退按钮.因此,如果您不想使用 NavigationHelper,以下是如何恢复旧行为:

                  This NavigationHelper gives you a hint how to properly react to back button press. So, if you don't want to use the NavigationHelper, here's how to get the old behavior back:

                  public BlankPage1()
                  {
                      this.InitializeComponent();
                      HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                  }
                  
                  void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
                  {
                      if (Frame.CanGoBack)
                      {
                          e.Handled = true;
                          Frame.GoBack();
                      }
                  }
                  

                  您也可以在应用级别执行此操作,以避免在每个页面上执行此操作:

                  You can also do it on app level, to avoid having to do it on every page:

                  public App()
                  {
                      this.InitializeComponent();
                      this.Suspending += this.OnSuspending;
                  
                      #if WINDOWS_PHONE_APP
                      HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                      #endif
                  }
                  
                  #if WINDOWS_PHONE_APP
                  void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
                  {
                      Frame rootFrame = Window.Current.Content as Frame;
                  
                      if (rootFrame != null && rootFrame.CanGoBack)
                      {
                          e.Handled = true;
                          rootFrame.GoBack();
                      }
                  }
                  #endif
                  

                  这篇关于Windows Phone 8.1 通用应用程序在从第二页返回时终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:.net core 1.1 中嵌入的 powerbi 下一篇:在 WP7 Silverlight 应用程序中导航时将复杂对象传递

                  相关文章

                  最新文章

                  <small id='c1347'></small><noframes id='c1347'>

                  <i id='c1347'><tr id='c1347'><dt id='c1347'><q id='c1347'><span id='c1347'><b id='c1347'><form id='c1347'><ins id='c1347'></ins><ul id='c1347'></ul><sub id='c1347'></sub></form><legend id='c1347'></legend><bdo id='c1347'><pre id='c1347'><center id='c1347'></center></pre></bdo></b><th id='c1347'></th></span></q></dt></tr></i><div id='c1347'><tfoot id='c1347'></tfoot><dl id='c1347'><fieldset id='c1347'></fieldset></dl></div>

                    • <bdo id='c1347'></bdo><ul id='c1347'></ul>
                    <legend id='c1347'><style id='c1347'><dir id='c1347'><q id='c1347'></q></dir></style></legend>
                    1. <tfoot id='c1347'></tfoot>