This topic has not yet been rated - Rate this topic

DeviceStatus.PowerSourceChanged Event

July 26, 2012

Occurs when the power source of the device changes.

Namespace:  Microsoft.Phone.Info
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)
public static event EventHandler PowerSourceChanged

For more information about the DeviceStatus API, see Device Status for Windows Phone.

The following code example shows how you can use the Dispatcher.BeginInvoke method and the PowerSourceChanged event handler to display a message when the device is disconnected from an external power source.

void DeviceStatus_PowerSourceChanged(object sender, EventArgs e)
{
    this.Dispatcher.BeginInvoke(DeviceDisconnectedFromPower);
}

void DeviceDisconnectedFromPower()
{
    if (DeviceStatus.PowerSource.ToString() != "External")
    {
        MessageBox.Show("Device is disconnected from an external power source.");
    }
}

Windows Phone OS

Supported in: 7.1

Windows Phone

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.