DeviceConnectionChangeTrigger DeviceConnectionChangeTrigger DeviceConnectionChangeTrigger DeviceConnectionChangeTrigger DeviceConnectionChangeTrigger Class


Represents a trigger that launches a background task when the connection status of a device changes.

public : sealed class DeviceConnectionChangeTrigger : IBackgroundTrigger, IDeviceConnectionChangeTrigger
struct winrt::Windows::ApplicationModel::Background::DeviceConnectionChangeTrigger : IBackgroundTrigger, IDeviceConnectionChangeTrigger
public sealed class DeviceConnectionChangeTrigger : IBackgroundTrigger, IDeviceConnectionChangeTrigger
Public NotInheritable Class DeviceConnectionChangeTrigger Implements IBackgroundTrigger, IDeviceConnectionChangeTrigger
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


CanMaintainConnection CanMaintainConnection CanMaintainConnection CanMaintainConnection CanMaintainConnection

Gets whether the system can maintain a connection to the specified device.

public : Platform::Boolean CanMaintainConnection { get; }
bool CanMaintainConnection();
public bool CanMaintainConnection { get; }
Public ReadOnly Property CanMaintainConnection As bool
var bool = deviceConnectionChangeTrigger.canMaintainConnection;
bool bool bool

True if the system can maintain a connection to the specified device; Otherwise, false. If false, an attempt to register a trigger with MaintainConnection = true will throw an exception. The default value of this property is true for Bluetooth LE devices and false for all other device types.

DeviceId DeviceId DeviceId DeviceId DeviceId

Gets the device Id associated with the device.

public : Platform::String DeviceId { get; }
winrt::hstring DeviceId();
public string DeviceId { get; }
Public ReadOnly Property DeviceId As string
var string = deviceConnectionChangeTrigger.deviceId;
string string string

The device Id associated with the device.


When monitoring Bluetooth LE devices, the DeviceId must reference an interface on the Bluetooth LE device object. The device Id in this case can be the values returned by the GetDeviceSelector. Alternatively, the DeviceId can reference an interface on a GattDeviceService object and valid values for the device Id is any value returned by GetDeviceSelectorFromShortId or GetDeviceSelectorFromUuid.

When monitoring other Bluetooth devices, the device Id can be any value returned by the GetDeviceSelector on RfCommDeviceService or BluetoothDevice.

MaintainConnection MaintainConnection MaintainConnection MaintainConnection MaintainConnection

Gets or sets whether the system should automatically attempt to keep the referenced device connected.

public : Platform::Boolean MaintainConnection { get; set; }
bool MaintainConnection(); void MaintainConnection(bool maintainconnection);
public bool MaintainConnection { get; set; }
Public ReadWrite Property MaintainConnection As bool
var bool = deviceConnectionChangeTrigger.maintainConnection;
deviceConnectionChangeTrigger.maintainConnection = bool;
bool bool bool

True of the system should try to keep the device connected; Otherwise, false. Default is false.


FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)

Begins an asynchronous operation to get the DeviceConnectionChangeTrigger associated with the specified Id.

public : static IAsyncOperation<DeviceConnectionChangeTrigger> FromIdAsync(Platform::String deviceId)
IAsyncOperation<DeviceConnectionChangeTrigger> FromIdAsync(winrt::hstring deviceId) const;
public static IAsyncOperation<DeviceConnectionChangeTrigger> FromIdAsync(String deviceId)
Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of DeviceConnectionChangeTrigger )
Windows.ApplicationModel.Background.DeviceConnectionChangeTrigger.fromIdAsync(deviceId).done( /* Your success and error handlers */ );
String String String

The device Id with which to find the associated trigger.


See Also