瀏覽代碼

Fix window width validation to avoid setting invalid MinWidth and MaxWidth

Ruben 4 月之前
父節點
當前提交
a6b9e7865a
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/PicView.Avalonia/UI/GenericWindowHelper.cs

+ 5 - 1
src/PicView.Avalonia/UI/GenericWindowHelper.cs

@@ -48,7 +48,11 @@ public static class GenericWindowHelper
     {
         window.Loaded += delegate
         {
-            window.MinWidth = window.MaxWidth = window.Width;
+            if (!double.IsNaN(window.Width) && !double.IsInfinity(window.Width))
+            {
+                window.MinWidth = window.MaxWidth = window.Width;
+            }
+            
             window.Title = title;
         };
         window.KeyDown += (_, e) =>