diff --git a/src/WinUIEx/WinUIEx.csproj b/src/WinUIEx/WinUIEx.csproj index 27b7e67..82bfb00 100644 --- a/src/WinUIEx/WinUIEx.csproj +++ b/src/WinUIEx/WinUIEx.csproj @@ -27,6 +27,7 @@ - Ensure WebAuthenticator URL is fully encoded to avoid issues with certain OAuth servers (#144) - Can't change TransparentTintBackdrop.TintColor at runtime (#149) - Avoid first-chance exception in Window Persistence + - Allow resetting MaxWidth/MaxHeight back to the default value of 0 diff --git a/src/WinUIEx/WindowManager.cs b/src/WinUIEx/WindowManager.cs index 91b2130..3beddf6 100644 --- a/src/WinUIEx/WindowManager.cs +++ b/src/WinUIEx/WindowManager.cs @@ -212,9 +212,9 @@ public double MaxWidth get => _maxWidth; set { - if(value <= 0) throw new ArgumentOutOfRangeException(nameof(value)); + if(value < 0) throw new ArgumentOutOfRangeException(nameof(value)); _maxWidth = value; - if (Width > value) + if (value > 0 && Width > value) Width = value; } } @@ -233,9 +233,9 @@ public double MaxHeight get => _maxHeight; set { - if (value <= 0) throw new ArgumentOutOfRangeException(nameof(value)); + if (value < 0) throw new ArgumentOutOfRangeException(nameof(value)); _maxHeight = value; - if (Height > value) + if (value > 0 && Height > value) Height = value; } } diff --git a/src/WinUIExSample/Pages/WindowControl.xaml.cs b/src/WinUIExSample/Pages/WindowControl.xaml.cs index 8588222..5f6cf47 100644 --- a/src/WinUIExSample/Pages/WindowControl.xaml.cs +++ b/src/WinUIExSample/Pages/WindowControl.xaml.cs @@ -93,8 +93,8 @@ private void limitMaxCheckbox_Toggled(object sender, RoutedEventArgs e) } else { - MainWindow.MaxWidth = double.NaN; - MainWindow.MaxHeight = double.NaN; + MainWindow.MaxWidth = 0; + MainWindow.MaxHeight = 0; } } public int WindowStateSelectedIndex