Samstag, 16. Oktober 2010

Windows Phone 7: Disable Screensaver (lock) during action

In our Windows Phone 7 project we need to disable the screensave (lock) of Windows Phone 7 for example during playing a media file in Mediaelement or during a picture slideshow. To reach this goal you can use the PhoneApplicationService.Current.UserIdleDetectionMode and set it to IdleDetectionMode.Enabled or IdleDetectionMode.Disabled.

 

Sample of a property

   1: public bool SlideshowIsActive
   2:        {
   3:            get { return _slideshowIsActive; }
   4:            set
   5:            {
   6:                if (_slideshowIsActive == value) return;
   7:  
   8:                _slideshowIsActive = value;
   9:  
  10:                PhoneApplicationService.Current.UserIdleDetectionMode = _slideshowIsActive ? IdleDetectionMode.Disabled : IdleDetectionMode.Enabled;
  11:  
  12:                NotifyPropertyChanged(() => SlideshowIsActive);
  13:            }
  14:        }

Keine Kommentare:

Kommentar veröffentlichen