Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for How to specify window size for a MAUI application in case of Windows platform?

$
0
0

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      }

Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>