Skip to content

Instantly share code, notes, and snippets.

@mecvillarina
Created January 16, 2023 01:57
Show Gist options
  • Save mecvillarina/48faca7dd1b1fa48a6b4bf4ad81d37aa to your computer and use it in GitHub Desktop.
Save mecvillarina/48faca7dd1b1fa48a6b4bf4ad81d37aa to your computer and use it in GitHub Desktop.
MAUI Starter Helpers
#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