-api-id | -api-type |
---|---|
T:Windows.Devices.Sensors.LightSensor |
winrt class |
Represents an ambient-light sensor that provides the ambient-light reading as a LUX value.
The following example demonstrates how a UWP app built with XAML and C# uses the GetDefault method to establish a connection to a light sensor. If no integrated light sensor is found, the method will return a null value.
[!code-csharpGetDefaultCS]
The following example demonstrates how a UWP app built with XAML registers a ReadingChanged event handler.
[!code-csharpEnableReadingChangedCS]
The following example shows the ReadingChanged event handler.
[!code-csharpReadingChangedCS]
Windows version | SDK version | Value added |
---|---|---|
1709 | 16299 | FromIdAsync |
1709 | 16299 | GetDeviceSelector |
1709 | 16299 | MaxBatchSize |
1709 | 16299 | ReportLatency |
2004 | 19041 | ReportThreshold |
For an example implementation, see the light sensor sample.