SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor Class


Represents a simple orientation sensor.

For an example implementation, see the simple orientation sensor sample.

This sensor detects the current quadrant orientation of the specified device as well as its face-up or face-down status.

public : sealed class SimpleOrientationSensor
struct winrt::Windows::Devices::Sensors::SimpleOrientationSensor
public sealed class SimpleOrientationSensor
Public NotInheritable Class SimpleOrientationSensor
// 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)


The following example demonstrates how a UWP app built with XAML and C# uses the GetDefault method to establish a connection to a simple orientation sensor. If no simple orientation sensor is found, the method will return a null value.

_sensor = SimpleOrientationSensor.GetDefault();

The following example demonstrates how a UWP app built with XAML registers a OrientationChanged event handler.

private void ScenarioEnable(object sender, RoutedEventArgs e)
    if (_sensor != null)
        Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(VisibilityChanged);
        _sensor.OrientationChanged += new TypedEventHandler<SimpleOrientationSensor, SimpleOrientationSensorOrientationChangedEventArgs>(OrientationChanged);

        ScenarioEnableButton.IsEnabled = false;
        ScenarioDisableButton.IsEnabled = true;

        // Display the current orientation once while waiting for the next orientation change
        DisplayOrientation(ScenarioOutput_Orientation, _sensor.GetCurrentOrientation());
        rootPage.NotifyUser("No simple orientation sensor found", NotifyType.StatusMessage);

The following example contains the XAML code for the event handler which writes the orientation readings to the application's form.

async private void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e)
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        DisplayOrientation(ScenarioOutput_Orientation, e.Orientation);
private void DisplayOrientation(TextBlock tb, SimpleOrientation orientation)
    switch (orientation)
        case SimpleOrientation.NotRotated:
            tb.Text = "Not Rotated";
        case SimpleOrientation.Rotated90DegreesCounterclockwise:
            tb.Text = "Rotated 90 Degrees Counterclockwise";
        case SimpleOrientation.Rotated180DegreesCounterclockwise:
            tb.Text = "Rotated 180 Degrees Counterclockwise";
        case SimpleOrientation.Rotated270DegreesCounterclockwise:
            tb.Text = "Rotated 270 Degrees Counterclockwise";
        case SimpleOrientation.Faceup:
            tb.Text = "Faceup";
        case SimpleOrientation.Facedown:
            tb.Text = "Facedown";
            tb.Text = "Unknown orientation";

Version history

Windows version SDK version Value added
1809 17763 FromIdAsync
1809 17763 GetDeviceSelector


DeviceId DeviceId DeviceId DeviceId DeviceId

Gets the device identifier used in the SimpleOrientationSensor.FromIdAsync method.

ReadingTransform ReadingTransform ReadingTransform ReadingTransform ReadingTransform

Gets or sets the transformation that needs to be applied to sensor data. Transformations to be applied are tied to the display orientation with which to align the sensor data.


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

Asynchronously retrieves a SimpleOrientationSensor object based on the specified device identifier.

GetCurrentOrientation() GetCurrentOrientation() GetCurrentOrientation() GetCurrentOrientation() GetCurrentOrientation()

Gets the default simple orientation sensor.

GetDefault() GetDefault() GetDefault() GetDefault() GetDefault()

Gets the default simple orientation sensor.

GetDeviceSelector() GetDeviceSelector() GetDeviceSelector() GetDeviceSelector() GetDeviceSelector()

Retrieves an Advanced Query Syntax (AQS) string used to enumerate the available SimpleOrientationSensor devices.


OrientationChanged OrientationChanged OrientationChanged OrientationChanged OrientationChanged

Occurs each time the simple orientation sensor reports a new sensor reading

See also