0%

WindowHelper

SetWindowSize

you can set your MainWindow Size:

1
WindowHelper.SetWindowSize(appWindow, 200, 300);

MoveAndResizeCenterScreen

1
WindowHelper.MoveAndResizeCenterScreen(window, width, height);

MoveAndResize

1
WindowHelper.MoveAndResize(window, x, y, width, height);

MoveAndResize

1
WindowHelper.Move(appWindow, x, y);

Window Height/Width Min/Max Size

you can set Window Height/Width Min/Max Size, first you need to register RegisterWindowMinMax method in your window class:

1
2
var windowHelper = new WindowHelper(window);
windowHelper.RegisterWindowMinMax();

now you can change window Min/Max size:

1
2
3
4
5
WindowHelper.MinWindowWidth = 500;
WindowHelper.MinWindowHeight = 300;

WindowHelper.MaxWindowWidth = 800;
WindowHelper.MaxWindowHeight = 600;

SwitchToThisWindow

1
2
3
4
5
6
WindowHelper.SwitchToThisWindow(window);

or

WindowHelper.SwitchToThisWindow(hwnd);

ReActivateWindow

1
2
3
4
5
6
WindowHelper.ReActivateWindow(window);

or

WindowHelper.ReActivateWindow(hwnd);

CreateWindowWithFrame

1
2
3
4
var windowWithFrame = WindowHelper.CreateWindowWithFrame();

//windowWithFrame.rootFrame
//windowWithFrame.window

SetWindowCornerRadius

1
2
3
4
5
6
WindowHelper.SetWindowCornerRadius(window, NativeValues.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND);

or

WindowHelper.SetWindowCornerRadius(hwnd, NativeValues.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND);

GetTopLevelWindows

1
var topWindows = WindowHelper.GetTopLevelWindows();

GetProcessWindowList

1
var processWindowList = WindowHelper.GetProcessWindowList();

GetWindowText

1
var windowText = WindowHelper.GetWindowText(hwnd);

GetClassName

1
var windowClassName = WindowHelper.GetClassName(hwnd);

GetCurrentAppWindow

1
var appWindow = WindowHelper.GetCurrentAppWindow();

GetAppWindow / GetAppWindow2

1
2
3
4
5
6
7
8
9

// Use XamlRoot
var appWindow = WindowHelper.GetAppWindow(element);

or

// Use Microsoft.UI.Composition.Visual
var appWindow = WindowHelper.GetAppWindow2(element);

GetWindowHandle / GetWindowHandle2

1
2
3
4
5
6
7
8
9

// Use XamlRoot
var hwnd = WindowHelper.GetWindowHandle(element);

or

// Use Microsoft.UI.Composition.Visual
var hwnd = WindowHelper.GetWindowHandle2(element);

Demo

you can run demo and see this feature.