在Windows手机中屏幕关闭时检测

时间:2011-10-25 09:18:28

标签: visual-studio windows-phone-7

有没有办法检测Windows手机屏幕何时关闭?当这种情况发生时,可以使应用程序运行吗?

1 个答案:

答案 0 :(得分:4)

您应该将ApplicationIdleDecectionMode设置为Enabled并处理根框架的ObscuredUnobscured事件:

Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;
      var rootFrame = App.Current.RootVisual as PhoneApplicationFrame;
      if(rootFrame != null)
      {
        rootFrame.Obscured += new EventHandler<ObscuredEventArgs>(rootFrame_Obscured);
        rootFrame.Unobscured += new EventHandler(rootFrame_Unobscured);
      }

详细了解article