Using Toggle Control to disable/enable idle detection – Windows Phone 7

Saw a question on Dream Build Launch on how can one use toggle control to disable / enable idle detection and from there, enable/disable it idle detection accordingly.

I believe he needed it in his setting page. Did up a quick demo.
















1. I used the toggle control from the silverlight toolkit for Windows Phone on codeplex (Can be found here : for the toggle control.

2. Do read this msdn article for

Things I did
1. Added the toggle controls in the toolkit into Visual Studio (if you have yet to do so)
2. Pull in the toggle controls and attached the checked event handler onto the control.
3. Add the following code (I included the method signature here).

private void toggleSwitch1_Checked(object sender, RoutedEventArgs e)

if (toggleSwitch1.IsChecked == true)
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;

You can download the demo file here :!2752&authkey=!AOBimFuXpsh6oog