Window markup reference
Window sizing modes, placement, lifecycle events, and window services.
Window
Section titled “Window”Receiver: Window and derived types (where T : Window).
| Method | Sets | Summary |
|---|---|---|
AllowsTransparency(bool value = true) |
AllowsTransparency |
Sets whether the window supports per-pixel transparency (platform dependent). |
Borderless(bool value = true) |
Borderless |
Sets whether the entire native non-client area (title bar and border) is removed. |
Build(Action<TWindow> build) |
Defines and immediately runs the window’s build at the composition site. The callback becomes the build owner (a virtual OnBuild override is then not invoked) and is re-run by Hot Reload when edited. | |
CanClose(bool value = true) |
CanClose |
Sets whether the native close button is enabled; the default is true. Keyboard shortcuts and Close still close the window; cancel Closing to keep it open. |
CanMaximize(bool value = true) |
CanMaximize |
Sets whether the maximize button is enabled; the default is true. |
CanMinimize(bool value = true) |
CanMinimize |
Sets whether the minimize button is enabled; the default is true. |
CreateBusyIndicator(string message = null, bool cancellable = false) |
Creates and shows a busy indicator overlay. Dispose the returned IBusyIndicator to dismiss. While active, window content is disabled and closing is prevented. | |
ExtendClientAreaTitleBarHeight(double value) |
ExtendClientAreaTitleBarHeight |
Sets the height in DIPs of the custom title bar area; a value above 0 extends the client area into the title bar while keeping the native frame, and 0 restores the default title bar. |
FitContentHeight(double fixedWidth, double maxHeight = 1000) |
Sets the window to fit content height. | |
FitContentSize(double maxWidth = 1000, double maxHeight = 1000) |
Sets the window to fit content size. | |
FitContentWidth(double fixedHeight, double maxWidth = 1000) |
Sets the window to fit content width. | |
Fixed(double width, double height) |
Sets the window as fixed size. | |
FullScreen(bool value = true) |
Puts the window into fullscreen, or restores it to normal when value is false. | |
Icon(IconSource value) |
Icon |
Sets the window icon. |
IsToolWindow(bool value = true) |
IsToolWindow |
Sets whether this is a floating tool window: a thin native title bar with move and close only, excluded from the taskbar, floating above its Owner. |
Maximized() |
WindowState = Maximized |
Sets the window state to maximized. |
Minimized() |
WindowState = Minimized |
Sets the window state to minimized. |
OnActivated(Action handler) |
event Activated |
Subscribes handler to Activated. Occurs when the window is activated. |
OnClosed(Action handler) |
event Closed |
Subscribes handler to Closed. Occurs when the window is closed. |
OnClosing(Action<ClosingEventArgs> handler) |
event Closing |
Subscribes handler to Closing. Occurs when the window is about to close; set Cancel to true to prevent it. |
OnDeactivated(Action handler) |
event Deactivated |
Subscribes handler to Deactivated. Occurs when the window is deactivated. |
OnDpiChanged(Action<uint, uint> handler) |
event DpiChanged |
Subscribes handler to DpiChanged. Occurs when the DPI changes. |
OnFirstFrameRendered(Action handler) |
event FirstFrameRendered |
Subscribes handler to FirstFrameRendered. Occurs when the first frame is rendered. |
OnFrameRendered(Action handler) |
event FrameRendered |
Subscribes handler to FrameRendered. Occurs after each frame is rendered. |
OnLoaded(Action handler) |
event Loaded |
Subscribes handler to Loaded. Occurs when the window is loaded and ready. |
OnPreviewKeyDown(Action<KeyEventArgs> handler) |
event PreviewKeyDown |
Subscribes handler to PreviewKeyDown. Occurs before the focused element receives a key press; a handled event is not delivered to it and the text input the keystroke would produce is dropped. |
OnPreviewKeyUp(Action<KeyEventArgs> handler) |
event PreviewKeyUp |
Subscribes handler to PreviewKeyUp. Occurs before the focused element receives a key release; a handled event is not delivered to it. |
OnPreviewTextCompositionEnd(Action<TextCompositionEventArgs> handler) |
event PreviewTextCompositionEnd |
Subscribes handler to PreviewTextCompositionEnd. Occurs before the focused element receives the end of an IME composition; a handled event is not delivered to it. |
OnPreviewTextCompositionStart(Action<TextCompositionEventArgs> handler) |
event PreviewTextCompositionStart |
Subscribes handler to PreviewTextCompositionStart. Occurs before the focused element receives the start of an IME composition; a handled event is not delivered to it. |
OnPreviewTextCompositionUpdate(Action<TextCompositionEventArgs> handler) |
event PreviewTextCompositionUpdate |
Subscribes handler to PreviewTextCompositionUpdate. Occurs before the focused element receives an IME composition update; a handled event is not delivered to it. |
OnPreviewTextInput(Action<TextInputEventArgs> handler) |
event PreviewTextInput |
Subscribes handler to PreviewTextInput. Occurs before the focused element receives text input; a handled event is not delivered to it. |
OnSizeChanged(Action<Size> handler) |
event ClientSizeChanged |
Adds a client size changed event handler. |
OnThemeChanged(Action<Theme, Theme> handler) |
event ThemeChanged |
Subscribes handler to ThemeChanged. Occurs when the theme changes. |
OnWindowStateChanged(Action<WindowState> handler) |
event WindowStateChanged |
Subscribes handler to WindowStateChanged. Raised when WindowState changes. |
PlatformOptions(PlatformWindowOptions value) |
PlatformOptions |
Sets the platform-specific window options; options for a mismatched platform throw InvalidOperationException at backend attach time. |
Resizable(double width, double height, double minWidth = 0, double minHeight = 0, double maxWidth = double.PositiveInfinity, double maxHeight = double.PositiveInfinity) |
Sets the window as resizable with optional min/max constraints. | |
ShowActivated(bool value = true) |
ShowActivated |
Sets whether showing the window activates it; where a platform cannot maximize without activating, a window shown maximized is activated regardless. |
ShowInTaskbar(bool value = true) |
ShowInTaskbar |
Sets whether the window appears in the taskbar. |
ShowToast(string text) |
Shows a toast notification that auto-dismisses after a duration based on text length. | |
StartCenterOwner() |
StartupLocation = CenterOwner |
Sets the window to open centered on the owner window. The owner is provided when calling Show or ShowDialogAsync. |
StartCenterScreen() |
StartupLocation = CenterScreen |
Sets the window to open centered on the primary screen. Must be called before Show. |
StartManualPosition(double leftDip, double topDip) |
Sets the window to open at the specified position in DIPs (primary monitor DPI basis). Must be called before Show. | |
StartupLocation(WindowStartupLocation value) |
StartupLocation |
Sets the initial window placement behavior, which must be set before Show is called. |
SystemBackdrop(SystemBackdrop value) |
SystemBackdrop |
Sets the material the platform shows behind the transparent parts of the window. It applies only while AllowsTransparency is set; a platform that cannot show the material lowers it to the nearest one it can, and where it can show none BackdropFallbackBrush is drawn under the background. |
Title(string value) |
Title |
Sets the window title. |
Topmost(bool value = true) |
Topmost |
Sets whether the window stays on top of other windows. |
UseLayoutRounding(bool value = true) |
UseLayoutRounding |
Sets whether layout rounding is enabled. |
WindowState(WindowState value) |
WindowState |
Sets the window display state. |