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

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

    1. 处理返回导航 Windows 10 (UWP)

      时间:2023-08-28
    2. <i id='MWWOU'><tr id='MWWOU'><dt id='MWWOU'><q id='MWWOU'><span id='MWWOU'><b id='MWWOU'><form id='MWWOU'><ins id='MWWOU'></ins><ul id='MWWOU'></ul><sub id='MWWOU'></sub></form><legend id='MWWOU'></legend><bdo id='MWWOU'><pre id='MWWOU'><center id='MWWOU'></center></pre></bdo></b><th id='MWWOU'></th></span></q></dt></tr></i><div id='MWWOU'><tfoot id='MWWOU'></tfoot><dl id='MWWOU'><fieldset id='MWWOU'></fieldset></dl></div>
      <tfoot id='MWWOU'></tfoot>
          <bdo id='MWWOU'></bdo><ul id='MWWOU'></ul>
            <legend id='MWWOU'><style id='MWWOU'><dir id='MWWOU'><q id='MWWOU'></q></dir></style></legend>
              <tbody id='MWWOU'></tbody>

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

              • 本文介绍了处理返回导航 Windows 10 (UWP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                在我的 Xaml 页面中,我有一个框架.

                In my Xaml Page I've got a Frame.

                我正在尝试让 backButton 事件在框架内导航.

                I'm trying to have a backButton event to just navigate inside frame .

                所以我尝试使用这段代码

                so I tried to use this piece of code

                public MainPage(){
                    this.InitializeComponent();
                    if(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) {
                        Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                    }
                }
                private void HardwareButtons_BackPressed(object sender,BackPressedEventArgs e) {
                    if(insideFrame.CanGoBack())insideFrame.GoBack();
                    else  Application.Current.Exit();
                }
                

                但在手机中执行 HardwareButtons_BackPressed 事件后它会关闭应用程序.

                but In phone after doing HardwareButtons_BackPressed event it close the application.

                似乎在 MainPage 上运行了一些默认的后退按钮行为...

                It seems to running some default back button behavior on MainPage...

                我该如何解决?在 Windows10 中他们是否添加了新事件来处理返回导航?

                How can I fix it? And In Windows10 does they add new events to handle back navigation?

                [更新]

                现在我发现在 Windows 10 中使用 SystemNavigationManager 比使用 Input.HardwareButtons.BackPressed 更好.

                Now I found out it's better to Use SystemNavigationManager in Windows 10 instead of Input.HardwareButtons.BackPressed.

                SystemNavigationManager currentView = SystemNavigationManager.GetForCurrentView();
                

                推荐答案

                您需要通过将 BackPressedEventArgs 的 Handled 属性设置为 true 来告诉系统您处理了后退按钮按下.

                You need to tell the system that you handled the backbutton press by setting the Handled property of the BackPressedEventArgs to true.

                  private void OnHardwareButtonsBackPressed(object sender, BackPressedEventArgs e)
                  {
                        // This is the missing line!
                        e.Handled = true;
                
                        // Close the App if you are on the startpage
                        if (mMainFrame.CurrentSourcePageType == typeof(Startpage))
                            App.Current.Exit();
                
                        // Navigate back
                        if (mMainFrame.CanGoBack)
                        {
                            mMainFrame.GoBack();
                        }
                  }
                

                这篇关于处理返回导航 Windows 10 (UWP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在 WP7 Silverlight 应用程序中导航时将复杂对象传递 下一篇:WPF 选项卡键导航

                相关文章

                最新文章

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

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

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