Customize Windows
Use AppWindow for top-level window behavior and title bar APIs for chrome customization.
Get AppWindow
using Microsoft.UI;
using Microsoft.UI.Windowing;
using WinRT.Interop;
var hwnd = WindowNative.GetWindowHandle(App.MainWindow);
var windowId = Win32Interop.GetWindowIdFromWindow(hwnd);
var appWindow = AppWindow.GetFromWindowId(windowId);
Resize Or Change Presenter
appWindow.Resize(new Windows.Graphics.SizeInt32(1200, 800));
if (AppWindowPresenter.Create(AppWindowPresenterKind.CompactOverlay) is AppWindowPresenter presenter)
{
appWindow.SetPresenter(presenter);
}
Title Bar Discipline
- Use simple title bar property changes before full custom title bars.
- If extending content into the title bar, handle drag regions and interactive controls carefully.
- Test DPI scaling and hit testing.
- Recheck current TitleBar control guidance before implementing new Windows App SDK 1.7+ title bar features.