diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressRing/WinUIDeterminateProgressRing.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressRing/WinUIDeterminateProgressRing.xaml.cs index d8cace980db4..df173742c9a2 100644 --- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressRing/WinUIDeterminateProgressRing.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/ProgressRing/WinUIDeterminateProgressRing.xaml.cs @@ -21,7 +21,10 @@ public WinUIDeterminateProgressRing() private void ProgressValue_SelectionChanged(object sender, SelectionChangedEventArgs e) { - ProgressRing.Value = double.Parse(ProgressValue.SelectedValue as string); + if (ProgressRing is { }) + { + ProgressRing.Value = double.Parse(ProgressValue.SelectedValue as string); + } } } } diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs index 1bbf45f45ca4..dac731e8c9df 100644 --- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs @@ -43,7 +43,7 @@ public sealed partial class TabViewPage : Page public TabViewPage() { this.InitializeComponent(); - Loaded += TabViewPage_Loaded; + DisabledTab.Loaded += TabViewPage_Loaded; _iconSource = new SymbolIconSource(); _iconSource.Symbol = Symbol.Placeholder; diff --git a/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml b/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml index 8dff273701f9..a187f8af8892 100644 --- a/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml @@ -14,6 +14,6 @@ - + diff --git a/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml.cs index cbfe25183b50..6616940fee65 100644 --- a/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_Devices/OrientationTests.xaml.cs @@ -12,21 +12,34 @@ public sealed partial class OrientationTests : Page { long lastTime; public OrientationTests() - { - this.InitializeComponent(); + { + this.InitializeComponent(); lastTime = DateTime.UtcNow.ToUnixTimeMilliseconds(); - SimpleOrientationSensor.GetDefault().OrientationChanged += OnSensorOrientationChanged; + this.Loaded += (s, e) => + { + var sensor = SimpleOrientationSensor.GetDefault(); + if (sensor is { }) + { + sensor.OrientationChanged += OnSensorOrientationChanged; + } + else + { + message.Text = "This device does not have an orientation sensor."; + } + }; } - private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) - { - var now = DateTime.UtcNow.ToUnixTimeMilliseconds(); - var diff = now - lastTime; - var s = diff / 1000; - var ms = diff % 1000; - timeSince.Text = $"~{s}.{ms} seconds since last orientation change."; - lastTime = now; - } - } + + private void OnSensorOrientationChanged(SimpleOrientationSensor sender, SimpleOrientationSensorOrientationChangedEventArgs args) + { + var now = DateTime.UtcNow.ToUnixTimeMilliseconds(); + + var diff = now - lastTime; + var s = diff / 1000; + var ms = diff % 1000; + timeSince.Text = $"~{s}.{ms} seconds since last orientation change."; + lastTime = now; + } + } }