Namespace
Inheritance
Control → TemplatedControl → TopLevel → WindowBase → Window
Properties
Gets or sets the title of the window. Default is “Window”.
Gets or sets the icon of the window.
Gets or sets the minimized/maximized state of the window. Values:
Normal, Minimized, Maximized, FullScreen.Gets or sets how the window will size itself to fit its content. Values:
Manual (default), Width, Height, WidthAndHeight.Gets or sets the startup location of the window. Values:
Manual, CenterScreen, CenterOwner.Gets or sets whether resizing of the window is enabled. Default is
true.Gets or sets whether minimizing the window is enabled. Default is
true.Gets or sets whether maximizing the window is enabled. Default is
true. When CanResize is false, this is always false.Gets or sets the window decorations (title bar, border, etc). Values:
None, BorderOnly, Full (default).Gets or sets whether a window is activated when first shown. Default is
true.Gets or sets whether the window appears in the taskbar. Default is
true.Gets or sets if the ClientArea is extended into the window decorations (chrome or border). Default is
false.Gets or sets the TitlebarHeightHint for when the client area is extended. -1 causes auto-sizing. Default is -1.
Gets if the ClientArea is extended into the window decorations. Read-only.
Gets the thickness around the window that is used by borders and the titlebar. Read-only.
Gets or sets how the Closing event behaves in the presence of child windows. Values:
OwnerAndChildWindows, OwnerWindowOnly.Gets or sets the window position in screen coordinates.
Gets whether this window was opened as a dialog. Read-only.
Gets a collection of child windows owned by this window. Read-only.
Events
Fired before a window is closed. Can be cancelled by setting
e.Cancel = true.Routed Events
Routed event for global tracking of opening windows.
Routed event for global tracking of window destruction.
Methods
Shows the window.
Shows the window as a child of the specified owner window.
Shows the window as a modal dialog.
Shows the window as a modal dialog and returns a result.
Closes the window.
Closes a dialog window with the specified result.
Hides the window but does not close it.
Starts moving a window with left button being held. Should be called from left mouse button press event handler.
Starts resizing a window. Should be called from left mouse button press event handler.
Protected Methods
Raises the Closing event. Override to add custom logic before the window closes.
Usage
XAML Example - Basic Window
XAML Example - Custom Window
C# Example - Creating and Showing Window
C# Example - Modal Dialog
C# Example - Dialog with Result
Handling Window Closing
Size to Content
Custom Title Bar
Enums
WindowState
Normal
The window is in its normal state.
Minimized
The window is minimized.
Maximized
The window is maximized.
FullScreen
The window is in full screen mode.
SizeToContent
Manual
The window will not automatically size itself to fit its content.
Width
The window will size itself horizontally to fit its content.
Height
The window will size itself vertically to fit its content.
WidthAndHeight
The window will size itself horizontally and vertically to fit its content.
WindowStartupLocation
Manual
The window position is determined by the Position property.
CenterScreen
The window is centered on the screen.
CenterOwner
The window is centered relative to its owner window.
Source File
Window.cs:1-1400+
See Also
- WindowBase - Base window class
- TopLevel - Top-level control
- Dialog - Dialog patterns