如何解决WP7中的循环导航问题或Back Loop问题?

Mil*_*tle 1 windows-phone-7

我有这个问题.我无法退出MainPage中的应用程序.

我开始从MainPage导航 - >第2页--->第3页.

在Page3中,我使用navigationService转到MainPage.有人可以帮我吗?

另外,我对这个术语e.cancel = true或false在重写BackKeyPress事件时感到困惑.

1.)e.Cancel = true表示取消后退?或者取消什么?2)e.cancel = false ,?

3)我是否需要在MainPage中覆盖backKey按?

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        try
        {
            base.OnBackKeyPress(e);

            if (NavigationService.CanGoBack)
            {
                e.Cancel = true; // yes cancel the default behavior ??
                NavigationService.GoBack();
            }

        }
        catch (Exception ex)
        {
           // MessageBox.Show("Error : " + ex.Message);
        }
    }
Run Code Online (Sandbox Code Playgroud)

3)针对此探针的任何解决方案?

谢谢

Mat*_*cey 6

您需要非线性导航服务.

它是为这种情况而设计的.只需从Page3导航回MainPage,它就会为您整理后备堆栈.无需手动触发额外的呼叫GoBack()等.