Skip to content

Commit

Permalink
Allow resetting MaxWidth/MaxHeight back to the default value of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten committed Feb 25, 2024
1 parent 0d65fcf commit 8756033
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/WinUIEx/WinUIEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/WinUIEx/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/WinUIExSample/Pages/WindowControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8756033

Please sign in to comment.