导航页面的新实例

发布于 2024-10-31 15:48:45 字数 295 浏览 6 评论 0原文

我的应用程序中有几个页面需要进行大约 2-3 分钟的 A-Synchronous 调用才能同步,用户可以在同步期间离开该页面,并可以在访问多个页面后再次返回,并且同步继续他也一直在其他页面上,当我从同步页面转到页面并按后退按钮时,一切正常..但是当我转到页面并从应用程序栏导航回同步页面时,会出现一个新的页面页面的实例已创建,同步就像重新启动一样。

现在我知道一切都工作正常,因为当我调用 NavigationService.Navigate() 时会创建页面的新实例,但在这种情况下我应该做什么?如何获取页面的旧实例(如果存在)?

谢谢...

I have a few pages in an Application that require A-Synchronous calls to be made for about 2-3 minutes to get Synchronized, the user may navigate away from that page during Synchronization and can come back again after visiting multiple pages and the sync continues all the time he is on other pages as well, when I go to a page from sync-page and press the Back button everything works fine.. but when i go to a page and navigate back to sync-page from Application Bar a new Instance of the Page is created and the Sync is just like Re-started.

Now i know every thing is working fine since new instance of a page is created when i call NavigationService.Navigate() , but what should i do in this scenario ? How to get the old instance of a page if it is there ?

Thanks...

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

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

发布评论

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

评论(1

翻身的咸鱼 2024-11-07 15:48:45

您无法获取页面的“旧”实例,并且不能保证向后导航将重新加载页面的前一个实例,它可能是同一页面的新实例,但恢复到相同的状态(假设您保存任何)。

如果您尝试从应用程序栏提供向后导航,那么 a) 您可能不应该这样做,因为这就是后退按钮的用途,b) 您应该确保使用 NavigationService.GoBack()而不是 NavigationService.Navigate(),因为 Navigate 始终会启动页面的新实例。

如果您想要访问的页面不是上一页,那么听起来您正在尝试实现非线性导航,应用中心

根据您的场景的声音,您应该单独处理这个长时间运行的过程(远离视图),然后当用户导航到相关页面时在视图中显示其进度或结果。

You can't get an "old" instance of a page and it's not guaranteed that a backwards navigation will reload the previous instance of the page, it may be a new instance of the same page, but restored to the same state (assuming you saved any).

If you are trying to provide backwards navigation from the application bar then a) you probably shouldn't because that's what the back button is for, and b) you should make sure you use NavigationService.GoBack() instead of NavigationService.Navigate() because Navigate will always launch a new instance of your page.

If the page you want to get to is not the previous page, then it sounds like you are trying to implement non-linear navigation for which there is a recipe on the App Hub.

By the sounds of your scenario, you should handle this long running process separately (away from the view) and then display it's progress or results in a view when the user navigates to the relevant page.

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