Minimum window size in .NET MAUI

112 Views Asked by At

Quick question that I cannot find any good answers to: I want my program window to be possible to resize on desktop. But there should be a minimum possible size to the window. How do I set this in .NET MAUI?

For example, with Avalonia, I do this by setting MinHeight="400" and MinWidth="800" in the XAML properties for <Window>.

1

There are 1 best solutions below

0
Guangyu Bai - MSFT On BEST ANSWER

You can override the CreateWindow method in the App.xaml.cs.

 protected override Window CreateWindow(IActivationState activationState)
 {
          var window = base.CreateWindow(activationState);
          window.MinimumHeight = 600; // set minimal window height
          window.MinimumWidth = 800; // set minimal window width
          return window;
 }