DeviceStatus.PowerSourceChanged Event
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Occurs when the power source of the device changes.
Namespace: Microsoft.Phone.Info
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
Syntax
Public Shared Event PowerSourceChanged As EventHandler
public static event EventHandler PowerSourceChanged
Examples
The following code example shows how you can use the Dispatcher..::.BeginInvoke method and the DeviceStatus..::.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.");
}
}
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1
Platforms
Windows Phone
See Also
Reference
Microsoft.Phone.Info Namespace