Share via


ProximitySensor Class

Definition

Provides an interface for a proximity sensor to determine whether or not an object is detected.

For an example implementation, see the proximity sensor sample.

public ref class ProximitySensor sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ProximitySensor final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ProximitySensor
Public NotInheritable Class ProximitySensor
Inheritance
Object Platform::Object IInspectable ProximitySensor
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

Version history

Windows version SDK version Value added
1511 10586 GetReadingsFromTriggerDetails

Properties

DeviceId

Gets the device identifier.

MaxDistanceInMillimeters

The largest distance where the proximity sensor can detect an object.

MinDistanceInMillimeters

The shortest distance where the proximity sensor can detect an object.

Methods

CreateDisplayOnOffController()

Creates a controller responsible for turning the display on or off based on the ProximitySensorReading.

FromId(String)

Obtains the proximity sensor from its identifier.

GetCurrentReading()

Gets the current reading for the proximity sensor.

GetDeviceSelector()

Gets the device selector.

GetReadingsFromTriggerDetails(SensorDataThresholdTriggerDetails)

Gets readings from the trigger details in background task.

Events

ReadingChanged

Occurs each time the proximity sensor reports a new value.

Applies to