相当于 Windows Phone 7 中的 onResume()

发布于 2024-11-29 07:00:06 字数 136 浏览 1 评论 0原文

我正在向 wp7 专家寻求一些应用程序生命周期帮助。我的应用程序在特定页面中有刷新步骤,但我只想在用户从后台启动应用程序时启动此步骤。

注意-仅当我导航(返回)或用户接听电话然后重新打开应用程序(保持同一页面打开)

提前谢谢您

I'm looking for some app life cycle help from the wp7 experts. My app has a refresh step in a specific page but I only want to launch this when the user brings the app to life from the background.

Note- The life cycle step I'm looking for isn't called when the page is init() only when I'm navigated (back) to or the user has taken a phone call and then re-opens the app (keeping the same page open)

Thank you in advance

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

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

发布评论

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

评论(1

别理我 2024-12-06 07:00:06

您正在寻找的称为墓碑化,您可以在 http://wildermuth 找到一篇很棒的文章.com/2010/10/17/Architecting_WP7_-_Part_5_of_10_Tombstoneing

这些事件是:

  • 启动(从磁贴打开)
  • 停用(用户接听电话或其他操作)
  • 激活(从通话中返回)
  • 关闭(通过“后退”按钮离开您的应用程序)

您正在寻找激活事件。这些位于您的 App.xaml.cs/vb 文件中。挂钩事件并更新您的数据模型。当您的页面绑定到该模型时,它将获取数据。

如果您没有使用 MVVM,并且无法真正从该事件刷新,则可以使用 PhoneApplicationService.Current.StartupMode 属性来执行此操作。它有两个选项激活(您正在寻找的内容)和启动(从磁贴中新鲜加载)。它看起来像

Init()
{
    if (PhoneApplicationService.Current.StartupMode ==  StartupMode.Activate)
    {
          Refresh()
    }
}

what you are looking for is called Tombstoning and you can find a great article at http://wildermuth.com/2010/10/17/Architecting_WP7_-_Part_5_of_10_Tombstoning

The events are:

  • Launching (opened from tile)
  • Deactivated (user takes a call or something)
  • Activated (back from the call)
  • Closing (Leaves you app via the "Back" button)

You are looking for the Activated event. These are in your App.xaml.cs/vb file. Hook into the event, and update your data model. When your page is bound to that model it will get the data.

If you are not using MVVM, and can't really refresh from that event, you can do it using the PhoneApplicationService.Current.StartupMode property. It has two options Activate (what you are looking for) and Launch (loaded fresh from the tile). It would look something like

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