【问题标题】:How to solve Circular navigation problem or Back Loop problem in WP7?如何解决 WP7 中的循环导航问题或返回循环问题?
【发布时间】:2013-04-25 18:11:29
【问题描述】:

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

我从 MainPage --> Page 2 ---> Page 3 开始导航。

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

我也对这个术语感到困惑 e.cancel = true or false in override the BackKeyPress Event。

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

3) 我需要覆盖 MainPage 中的 backKey press 吗?

    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);
        }
    }

3) 有针对此问题的解决方案吗?

谢谢

【问题讨论】:

    标签: windows-phone-7


    【解决方案1】:

    您需要Non-Linear Navigation Service

    它就是为这种情况而设计的。只需从 Page3 导航回 MainPage,它就会为您整理出后台堆栈。无需手动触发对GoBack()等的额外调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 2019-07-09
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多