none
windows phone8.1应用删除页面后退栈 RRS feed

  • 问题

  • 我新建的是windows phone8.1应用,因此在类库空间里面找不到NavigationService.RemoveBackEntry(),请问这个时候该如何移除页面后退栈
    2015年1月4日 11:08

答案

  • 你好,

    我们可以在导航页面后清楚后退栈:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
                Frame.Navigate(typeof(BlankPage1));
    
                if (this.Frame.CanGoBack)
                {
                    this.Frame.BackStack.RemoveAt(0);
                }
    }

    如果只是想禁用后退按钮,可以处理HardwareButtons.BackPressed事件:

    public MainPage()
    {
                this.InitializeComponent();
    
                this.NavigationCacheMode = NavigationCacheMode.Required;
    
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
    }
    
    void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
    {
                if (Frame.CanGoBack)
                {
                    e.Handled = true;
                }
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 蔡鸿军 2015年1月13日 6:20
    2015年1月5日 10:11
    版主