diff --git a/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.cs b/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.cs
index 6134dac8..58bf452f 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Controls/D2D1AnimatedPixelShaderPanel.cs
@@ -79,7 +79,41 @@ public sealed class D2D1AnimatedPixelShaderPanel : Control
// Pause or start the render thread if a runner is available
if (@this.canvasAnimatedControl is { } canvasAnimatedControl)
{
- canvasAnimatedControl.Paused = e.NewValue is not ID2D1ShaderRunner;
+ bool shouldRender = @this.IsLoaded && !@this.IsPaused && shaderRunner is not null;
+
+ canvasAnimatedControl.Paused = !shouldRender;
+ }
+ }
+
+ ///
+ /// Gets or sets whether or not the rendering is paused.
+ ///
+ public bool IsPaused
+ {
+ get => (bool)GetValue(IsPausedProperty);
+ set => SetValue(IsPausedProperty, value);
+ }
+
+ ///
+ /// The backing .
+ ///
+ public static readonly DependencyProperty IsPausedProperty = DependencyProperty.Register(
+ nameof(IsPaused),
+ typeof(bool),
+ typeof(D2D1AnimatedPixelShaderPanel),
+ new PropertyMetadata(false, OnIsPausedPropertyChanged));
+
+ ///
+ private static void OnIsPausedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ D2D1AnimatedPixelShaderPanel @this = (D2D1AnimatedPixelShaderPanel)d;
+ bool isPaused = (bool)e.NewValue;
+
+ if (@this.canvasAnimatedControl is { } canvasAnimatedControl)
+ {
+ bool shouldRender = @this.IsLoaded && !isPaused && @this.ShaderRunner is ID2D1ShaderRunner;
+
+ canvasAnimatedControl.Paused = !shouldRender;
}
}
}
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
index 116aabab..b2500725 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
+++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
@@ -148,7 +148,6 @@
-
+