This file contains hidden or 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
| public static class WindowExtensions | |
| { | |
| public static void SetSize(this Window window, int width, int height) | |
| { | |
| // To set the size you need to wrap the XAML window in AppWindow | |
| var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window); | |
| var windowsId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hwnd); | |
| var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowsId); | |
| // Notice that AppWindow uses raw pixels because it's a low level API. |