From 3b3e45adbb793baa5df0cfb6ccf9f050ca751338 Mon Sep 17 00:00:00 2001 From: CascadePass <106619481+CascadePass@users.noreply.github.com> Date: Sun, 3 Aug 2025 17:41:10 -0700 Subject: [PATCH] Null check Add null check for knob before using. --- CPAP-Exporter.UI/ToggleSwitch.xaml.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CPAP-Exporter.UI/ToggleSwitch.xaml.cs b/CPAP-Exporter.UI/ToggleSwitch.xaml.cs index 3e8ecc3..5f27285 100644 --- a/CPAP-Exporter.UI/ToggleSwitch.xaml.cs +++ b/CPAP-Exporter.UI/ToggleSwitch.xaml.cs @@ -230,6 +230,11 @@ public Brush KnobDisabledBackgroundBrush private void AnimateKnob(bool isChecked) { + if (this.knob is null) + { + return; + } + double margin = this.knob.Margin.Left + this.knob.Margin.Right; double travelDistance = this.track.ActualWidth - this.knob.ActualWidth - margin;