If you want to specify a minimal window width and a minimal window height only, you can make the project's target framwork as .net 7.0. And then override the App's CreateWindow method:
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; }
And you can also use the handler to resize the window. In the page.cs:
protected override void OnHandlerChanged() { base.OnHandlerChanged();#if WINDOWS Microsoft.UI.Xaml.Window? window = (Microsoft.UI.Xaml.Window?)(App.Current?.Windows.First<Window>().Handler.PlatformView); if(window == null){ return; } IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window); Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle); Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId); appWindow.Resize(new Windows.Graphics.SizeInt32(800,600));#endif }