WP7 SplashPage 导航问题 - 后退按钮和退出

发布于 2024-12-01 11:11:14 字数 851 浏览 1 评论 0 原文

我有这样的东西:

SplashPage ->主页 ->设置-> About

SplashPage 只是带有我的徽标和动画的页面,持续约 1 秒,然后我将用户重定向到 MainPage。第一个问题是,当我按主页上的后退按钮时,我回到了初始页面,这不太好。我通过这段代码解决了这个问题:

private bool navigateBack;

        public SplashPage()
        {
            InitializeComponent();

            navigateBack = false;
        }

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (navigateBack)
            {
                this.NavigationService.GoBack();
            }
            else
            {
                navigateBack = true;
                base.OnNavigatedTo(e);
            }
        }

这样在按下后退按钮时,用户再也不会看到启动页面,但我遇到了奇怪的问题。应用程序抛出导航异常,CanGoBack 属性为 false 并且应用程序退出。确实,我想退出应用程序,但不使用异常,因为我将无法通过市场认证。

我的问题是如何从 MainPage 导航回来并退出应用程序,但没有抛出异常。先感谢您!

I have something like this :

SplashPage -> MainPage -> Settings -> About

SplashPage is only page with my logo and animation for about 1 second, and then I redirect my user to MainPage. First problem was that when I press back button on MainPage, I'm back to splashpage and that wasn't good. I solved that by this piece of code :

private bool navigateBack;

        public SplashPage()
        {
            InitializeComponent();

            navigateBack = false;
        }

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (navigateBack)
            {
                this.NavigationService.GoBack();
            }
            else
            {
                navigateBack = true;
                base.OnNavigatedTo(e);
            }
        }

This way on back button press, user never see splashpage again, but I have weird problem. Application is throwing Navigation Exception that CanGoBack property is false and application exit. It's true, that I want to exit from app, but not using exception, because I will fail certification in marketplace.

My question is how to navigate back from MainPage and exit application, but with no exception thrown. Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

明天过后 2024-12-08 11:11:14

为初始屏幕引入单独的页面会带来比它解决的问题更多的问题(正如您所发现的),因此我建议在主页上使用覆盖层。我[不久前发布了有关使用闪屏和这种情况的文章。

Introducing a separate page for your splash screen introduces more problems than it solves (as you're finding out), so I'd reccomend using an overlay on your main page instead. I [posted about using splash screens and this very situation a while back.

山川志 2024-12-08 11:11:14

在Mango中,您可以使用

NavigationService.RemoveBackEntry()

从页面堆栈中删除页面,即您点击MainPage后立即删除的splashpage

,因此如果您将splashpage转移到mainpage,您将调用该函数两次

第一次从页面堆栈中删除 MainPage 和第二次从页面堆栈中删除 SplashPage 时,您会注意到,当您现在按返回键时,您将关闭该应用程序

in Mango you can use

NavigationService.RemoveBackEntry()

to remove a page from your page stack, i.e your splashpage as soon as you hit your MainPage

so if you have your splashpage to mainpage you would call the function twice

the first time to remove MainPage from the page stack and the second time to remove SplashPage from the page stack, you will notice that when you press the back key now you will close the app

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文