Created
January 16, 2023 01:57
-
-
Save mecvillarina/48faca7dd1b1fa48a6b4bf4ad81d37aa to your computer and use it in GitHub Desktop.
MAUI Starter Helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if WINDOWS | |
using Microsoft.UI; | |
using Microsoft.UI.Windowing; | |
using Windows.Graphics; | |
#endif | |
const int WindowWidth = 540; | |
const int WindowHeight = 1000; | |
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) => | |
{ | |
#if WINDOWS | |
var mauiWindows = handler.VirtualView; | |
var nativeWindow = handler.PlatformView; | |
nativeWindow.Activate(); | |
IntPtr windowHandler = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow); | |
WindowId windowId = Win32Interop.GetWindowIdFromWindow(windowHandler); | |
AppWindow appWindow = AppWindow.GetFromWindowId(windowId); | |
appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight)); | |
#endif | |
}); | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment