diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs index 1de76d4f04..8c65aa1b33 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKXamlCanvas.cs @@ -15,7 +15,7 @@ public partial class SKXamlCanvas : Canvas private IntPtr pixels; private WriteableBitmap bitmap; - private double dpi; + private double dpi = 1; private bool ignorePixelScaling; public SKXamlCanvas() @@ -28,9 +28,12 @@ private void Initialize() if (designMode) return; - SizeChanged += OnSizeChanged; - Unloaded += OnUnloaded; + var display = DisplayInformation.GetForCurrentView(); + OnDpiChanged(display); + Loaded += OnLoaded; + Unloaded += OnUnloaded; + SizeChanged += OnSizeChanged; } public SKSize CanvasSize => bitmap == null ? SKSize.Empty : new SKSize(bitmap.PixelWidth, bitmap.PixelHeight);