diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
index 331a34da4a46..6615273a17be 100644
--- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
+++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
@@ -514,6 +514,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -5555,6 +5559,9 @@
LampTests.xaml
+
+ CompassTests.xaml
+
LightSensorTests.xaml
diff --git a/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml b/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml
new file mode 100644
index 000000000000..765eaf817344
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ HeadingMagneticNorth:
+
+
+
+ Timestamp:
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml.cs
new file mode 100644
index 000000000000..3b85069ac4bf
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_Devices/CompassTests.xaml.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Uno.Disposables;
+using Uno.UI.Samples.Controls;
+using Uno.UI.Samples.UITests.Helpers;
+using Windows.Devices.Sensors;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Core;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace UITests.Shared.Windows_Devices
+{
+ [Sample(
+ "Windows.Devices",
+ Name = "Compass",
+ Description = "Demonstrates use of Windows.Devices.Sensors.Compass",
+ ViewModelType = typeof(CompassTestsViewModel),
+ IgnoreInSnapshotTests = true)]
+ public sealed partial class CompassTests : UserControl
+ {
+ public CompassTests()
+ {
+ this.InitializeComponent();
+
+ }
+
+ [Bindable]
+ internal class CompassTestsViewModel : ViewModelBase
+ {
+ private Compass _compass;
+ private bool _readingChangedAttached;
+ private string _sensorStatus;
+ private double _headingMagneticNorth;
+ private string _timestamp;
+
+ public CompassTestsViewModel(CoreDispatcher dispatcher) : base(dispatcher)
+ {
+
+ _compass = Compass.GetDefault();
+ if (_compass != null)
+ {
+ _compass.ReportInterval = 250;
+ SensorStatus = "Compass created";
+ }
+ else
+ {
+ SensorStatus = "Compass not available on this device";
+ }
+ Disposables.Add(Disposable.Create(() =>
+ {
+ if (_compass != null)
+ {
+ _compass.ReadingChanged -= Compass_ReadingChanged;
+ }
+ }));
+ }
+
+ public Command AttachReadingChangedCommand => new Command((p) =>
+ {
+ _compass.ReadingChanged += Compass_ReadingChanged;
+ ReadingChangedAttached = true;
+ });
+
+ public Command DetachReadingChangedCommand => new Command((p) =>
+ {
+ _compass.ReadingChanged -= Compass_ReadingChanged;
+ ReadingChangedAttached = false;
+ });
+
+ public bool CompassAvailable => _compass != null;
+
+ public string SensorStatus
+ {
+ get => _sensorStatus;
+ private set
+ {
+ _sensorStatus = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ public bool ReadingChangedAttached
+ {
+ get => _readingChangedAttached;
+ private set
+ {
+ _readingChangedAttached = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ public double HeadingMagneticNorth
+ {
+ get => _headingMagneticNorth;
+ private set
+ {
+ _headingMagneticNorth = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ public string Timestamp
+ {
+ get => _timestamp;
+ private set
+ {
+ _timestamp = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private async void Compass_ReadingChanged(Compass sender, CompassReadingChangedEventArgs args)
+ {
+ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
+ {
+ HeadingMagneticNorth = args.Reading.HeadingMagneticNorth;
+ Timestamp = args.Reading.Timestamp.ToString("R");
+ });
+ }
+ }
+ }
+}