Windows Phone 8.1 - Page Navigation

前端 未结 4 1696
无人共我
无人共我 2020-12-01 05:11

Coming from Windows Phone 8 I have never thought there will be a lot of changes done to the Windows Phone 8.1 code. Basically I\'m just wondering h

4条回答
  •  时光说笑
    2020-12-01 05:48

    In case you want to go back you can use:

    if(this.Frame.CanGoBack)
    {
    this.Frame.GoBack();
    }
    

    If you want to go back on the click of back button, you need to override the hardwarebutton event:

    HardwareButtons.BackPressed += HardwareButtons_BackPressed;
    
    void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if(rootFrame != null && rootFrame.CanGoBack)
                {
                    rootFrame.GoBack();
                    e.Handled = true;
                }
    
            }
    

    Make sure to set e.Handled to true.

提交回复
热议问题