SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor SimpleOrientationSensor Class


Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
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 : ISimpleOrientationSensor, ISimpleOrientationSensor2, ISimpleOrientationSensorDeviceId
struct winrt::Windows::Devices::Sensors::SimpleOrientationSensor : ISimpleOrientationSensor, ISimpleOrientationSensor2, ISimpleOrientationSensorDeviceId
public sealed class SimpleOrientationSensor : ISimpleOrientationSensor, ISimpleOrientationSensor2, ISimpleOrientationSensorDeviceId
Public NotInheritable Class SimpleOrientationSensor Implements ISimpleOrientationSensor, ISimpleOrientationSensor2, ISimpleOrientationSensorDeviceId
// 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";


DeviceId DeviceId DeviceId DeviceId DeviceId

Gets the device identifier.

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.


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

Gets the default simple orientation sensor.

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

Gets the default simple orientation sensor.


OrientationChanged OrientationChanged OrientationChanged OrientationChanged OrientationChanged

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

See Also