Window Class
Definition
A top-level window.
public class Window
Constructors
| Name | Description |
|---|---|
| Window (2 overloads) | Initializes a new instance of the Avalonia.Controls.Window class. |
Window overloads
Window Constructor
Initializes a new instance of the Avalonia.Controls.Window class.
public Window()
Window Constructor
Initializes a new instance of the Avalonia.Controls.Window class.
public Window(Avalonia.Platform.IWindowImpl impl)
Parameters
impl Avalonia.Platform.IWindowImpl
The window implementation.
Methods
| Name | Description |
|---|---|
| Activate | Activates the window. Inherited from WindowBase. |
| AddHandler (2 overloads) | Adds a handler for the specified routed event. Inherited from Interactive. |
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| ApplyTemplate | Creates the visual children of the control, if necessary Inherited from TemplatedControl. |
| Arrange | Arranges the control and its children. Inherited from Layoutable. |
| BeginInit | Inherited from StyledElement. |
| BeginMoveDrag | Starts moving a window with left button being held. Should be called from left mouse button press event handler |
| BeginResizeDrag | Starts resizing a window. This function is used if an application has window resizing controls. Should be called from left mouse button press event handler |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject. |
| ClearValue (4 overloads) | Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject. |
| Close (2 overloads) | Closes the window. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| EndInit | Inherited from StyledElement. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| Focus | Focuses the control. Inherited from InputElement. |
| GetAutoSafeAreaPadding | Gets if auto safe area padding is enabled. Inherited from TopLevel. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetFlowDirection | Gets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetIsHoldingEnabled | Inherited from InputElement. |
| GetIsHoldWithMouseEnabled | Inherited from InputElement. |
| GetIsTemplateFocusTarget | Gets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| GetSystemBarColor | Helper for getting the color of the platform's system bars. Inherited from TopLevel. |
| GetTopLevel | Gets the Avalonia.Controls.TopLevel for which the given Avalonia.Visual is hosted in. Inherited from TopLevel. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| Hide | Hides the window but does not close it. |
| InvalidateArrange | Invalidates the arrangement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateMeasure | Invalidates the measurement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateVisual | Invalidates the visual and queues a repaint. Inherited from Visual. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsSet | Checks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject. |
| Measure | Carries out a measure of the control. Inherited from Layoutable. |
| RaiseEvent | Raises a routed event. Inherited from Interactive. |
| RemoveHandler (2 overloads) | Removes a handler for the specified routed event. Inherited from Interactive. |
| Render | Renders the visual to a Avalonia.Media.DrawingContext. Inherited from Visual. |
| RequestAnimationFrame | Inherited from TopLevel. |
| RequestPlatformInhibition | Requests a Avalonia.Controls.PlatformInhibitionType to be inhibited. The behavior remains inhibited until the return value is disposed. The available set of Avalonia.Controls.PlatformInhibitionTypes depends on the platform. If a behavior is inhibited on a platform where this type is not supported the request will have no effect. Inherited from TopLevel. |
| SetAutoSafeAreaPadding | Enabled or disables whenever TopLevel should automatically adjust paddings depending on the safe area. Inherited from TopLevel. |
| SetCurrentValue (2 overloads) | Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject. |
| SetFlowDirection | Sets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| SetIsHoldingEnabled | Inherited from InputElement. |
| SetIsHoldWithMouseEnabled | Inherited from InputElement. |
| SetIsTemplateFocusTarget | Sets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| SetSystemBarColor | Gets or sets the keyboard navigation handler for the window. Inherited from TopLevel. |
| SetValue (3 overloads) | Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| Show (2 overloads) | Shows the window. |
| ShowDialog | Shows the window as a dialog. |
| SortWindowsByZOrder | No summary available. |
| TryGetPlatformHandle | Trys to get the platform handle for the TopLevel-derived control. Inherited from TopLevel. |
| TryGetResource | Inherited from StyledElement. |
| UpdateLayout | Executes a layout pass. Inherited from Layoutable. |
| VerifyAccess | Checks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject. |
BeginMoveDrag Method
Starts moving a window with left button being held. Should be called from left mouse button press event handler
public void BeginMoveDrag(Avalonia.Input.PointerPressedEventArgs e)
Parameters
BeginResizeDrag Method
Starts resizing a window. This function is used if an application has window resizing controls. Should be called from left mouse button press event handler
public void BeginResizeDrag(Avalonia.Controls.WindowEdge edge, Avalonia.Input.PointerPressedEventArgs e)
Parameters
Close overloads
Close Method
Closes the window.
public void Close()
Close Method
Closes a dialog window with the specified result.
public void Close(object dialogResult)
Parameters
dialogResult object
The dialog result.
Remarks
When the window is shown with the Avalonia.Controls.Window.ShowDialog<T>(Avalonia.Controls.Window) or Avalonia.Controls.Window.ShowDialog<T>(Avalonia.Controls.Window) method, the resulting task will produce the Avalonia.Controls.Window._dialogResult value when the window is closed.
Hide Method
Hides the window but does not close it.
public void Hide()
Show overloads
Show Method
Shows the window.
public void Show()
Exceptions
Show Method
Shows the window as a child of owner.
public void Show(Avalonia.Controls.Window owner)
Parameters
owner Avalonia.Controls.Window
Window that will be the owner of the shown window.
Exceptions
ShowDialog Method
Shows the window as a dialog.
public System.Threading.Tasks.Task<TResult> ShowDialog<TResult>(Avalonia.Controls.Window owner)
Parameters
owner Avalonia.Controls.Window
The dialog's owner window.
Returns
System.Threading.Tasks.Task
A task that can be used to track the lifetime of the dialog.
Exceptions
SortWindowsByZOrder Method
public void SortWindowsByZOrder(Span<Avalonia.Controls.Window> windows)
Parameters
windows Span<Avalonia.Controls.Window>
Properties
| Name | Description |
|---|---|
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| ActualTransparencyLevel | Gets the achieved Avalonia.Controls.WindowTransparencyLevel that the platform was able to provide. Inherited from TopLevel. |
| Background | Gets or sets the brush used to draw the control's background. Inherited from TemplatedControl. |
| BackgroundSizing | Gets or sets how the control's background is drawn relative to the control's border. Inherited from TemplatedControl. |
| BorderBrush | Gets or sets the brush used to draw the control's border. Inherited from TemplatedControl. |
| BorderThickness | Gets or sets the thickness of the control's border. Inherited from TemplatedControl. |
| Bounds | Gets the bounds of the control relative to its parent. Inherited from Visual. |
| CacheMode | Gets or sets the cache mode of the visual. Inherited from Visual. |
| CanMaximize | Enables or disables maximizing the window. |
| CanMinimize | Enables or disables minimizing the window. |
| CanResize | Enables or disables resizing of the window. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| ClientSize | Gets or sets the client size of the window. Inherited from TopLevel. |
| Clip | Gets or sets the geometry clip for this visual. Inherited from Visual. |
| Clipboard | Gets the platform's clipboard implementation Inherited from TopLevel. |
| ClipToBounds | Gets or sets a value indicating whether the control should be clipped to its bounds. Inherited from Visual. |
| ClosingBehavior | Gets or sets a value indicating how the Avalonia.Controls.Window.Closing event behaves in the presence of child windows. |
| Content | Gets or sets the content to display. Inherited from ContentControl. |
| ContentTemplate | Gets or sets the data template used to display the content of the control. Inherited from ContentControl. |
| ContextFlyout | Gets or sets a context flyout to the control Inherited from Control. |
| ContextMenu | Gets or sets a context menu to the control. Inherited from Control. |
| CornerRadius | Gets or sets the radius of the border rounded corners. Inherited from TemplatedControl. |
| Cursor | Gets or sets associated mouse cursor. Inherited from InputElement. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| DataTemplates | Gets or sets the data templates for the control. Inherited from Control. |
| DesiredSize | Gets the size that this element computed during the measure pass of the layout process. Inherited from Layoutable. |
| DesktopScaling | Gets the scaling factor for Window positioning and sizing. Inherited from WindowBase. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| Effect | Gets or sets the effect of the control. Inherited from Visual. |
| ExtendClientAreaTitleBarHeightHint | Gets or Sets the TitlebarHeightHint for when the client area is extended. A value of -1 will cause the titlebar to be auto sized to the OS default. Any other positive value will cause the titlebar to assume that height. |
| ExtendClientAreaToDecorationsHint | Gets or sets if the ClientArea is Extended into the Window Decorations (chrome or border). |
| FlowDirection | Gets or sets the text flow direction. Inherited from Visual. |
| Focusable | Gets or sets a value indicating whether the control can receive focus. Inherited from InputElement. |
| FocusAdorner | Gets or sets the control's focus adorner. Inherited from Control. |
| FocusManager | Gets focus manager of the root. Inherited from TopLevel. |
| FontFamily | Gets or sets the font family used to draw the control's text. Inherited from TemplatedControl. |
| FontFeatures | Gets or sets the font features turned on/off. Inherited from TemplatedControl. |
| FontSize | Gets or sets the size of the control's text in points. Inherited from TemplatedControl. |
| FontStretch | Gets or sets the font stretch used to draw the control's text. Inherited from TemplatedControl. |
| FontStyle | Gets or sets the font style used to draw the control's text. Inherited from TemplatedControl. |
| FontWeight | Gets or sets the font weight used to draw the control's text. Inherited from TemplatedControl. |
| Foreground | Gets or sets the brush used to draw the control's text and other foreground elements. Inherited from TemplatedControl. |
| FrameSize | Gets or sets the total size of the window. Inherited from TopLevel. |
| GestureRecognizers | Inherited from InputElement. |
| HasMirrorTransform | Gets or sets a value indicating whether to apply mirror transform on this control. Inherited from Visual. |
| Height | Gets or sets the height of the element. Inherited from Layoutable. |
| HorizontalAlignment | Gets or sets the element's preferred horizontal alignment in its parent. Inherited from Layoutable. |
| HorizontalContentAlignment | Gets or sets the horizontal alignment of the content within the control. Inherited from ContentControl. |
| Icon | Gets or sets the icon of the window. |
| InputPane | Inherited from TopLevel. |
| InsetsManager | Inherited from TopLevel. |
| IsActive | Gets a value that indicates whether the window is active. Inherited from WindowBase. |
| IsArrangeValid | Gets a value indicating whether the control's layouts arrange is valid. Inherited from Layoutable. |
| IsDialog | Gets whether this window was opened as a dialog |
| IsEffectivelyEnabled | Gets a value indicating whether this control and all its parents are enabled. Inherited from InputElement. |
| IsEffectivelyVisible | Gets a value indicating whether this control and all its parents are visible. Inherited from Visual. |
| IsEnabled | Gets or sets a value indicating whether the control is enabled for user interaction. Inherited from InputElement. |
| IsExtendedIntoWindowDecorations | Gets if the ClientArea is Extended into the Window Decorations. |
| IsFocused | Gets a value indicating whether the control is focused. Inherited from InputElement. |
| IsHitTestVisible | Gets or sets a value indicating whether the control is considered for hit testing. Inherited from InputElement. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| IsKeyboardFocusWithin | Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. Inherited from InputElement. |
| IsLoaded | Gets a value indicating whether the control is fully constructed in the visual tree and both layout and render are complete. Inherited from Control. |
| IsMeasureValid | Gets a value indicating whether the control's layout measure is valid. Inherited from Layoutable. |
| IsPointerOver | Gets a value indicating whether the pointer is currently over the control. Inherited from InputElement. |
| IsTabStop | Gets or sets a value that indicates whether the control is included in tab navigation. Inherited from InputElement. |
| IsVisible | Gets or sets a value indicating whether this control is visible. Inherited from Visual. |
| Item | Inherited from AvaloniaObject. |
| KeyBindings | Inherited from InputElement. |
| Launcher | Inherited from TopLevel. |
| LetterSpacing | Gets or sets the letter spacing for the control's text content. Inherited from TemplatedControl. |
| Margin | Gets or sets the margin around the element. Inherited from Layoutable. |
| MaxHeight | Gets or sets the maximum height of the element. Inherited from Layoutable. |
| MaxWidth | Gets or sets the maximum width of the element. Inherited from Layoutable. |
| MinHeight | Gets or sets the minimum height of the element. Inherited from Layoutable. |
| MinWidth | Gets or sets the minimum width of the element. Inherited from Layoutable. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| OffScreenMargin | Gets the window margin that is hidden off the screen area. This is generally only the case on Windows when in Maximized where the window border is hidden off the screen. This Margin may be used to ensure user content doesnt overlap this space. |
| Opacity | Gets or sets the opacity of the control. Inherited from Visual. |
| OpacityMask | Gets or sets the opacity mask of the control. Inherited from Visual. |
| OwnedWindows | Gets a collection of child windows owned by this window. |
| Owner | Gets or sets the owner of the window. Inherited from WindowBase. |
| Padding | Gets or sets the padding placed between the border of the control and its content. Inherited from TemplatedControl. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| PlatformImpl | Gets the platform-specific window implementation. |
| Position | Gets or sets the window position in screen coordinates. |
| Presenter | Gets the presenter from the control's template. Inherited from ContentControl. |
| RendererDiagnostics | Gets a value indicating whether the renderer should draw specific diagnostics. Inherited from TopLevel. |
| RenderScaling | Inherited from TopLevel. |
| RenderTransform | Gets or sets the render transform of the control. Inherited from Visual. |
| RenderTransformOrigin | Gets or sets the transform origin of the control. Inherited from Visual. |
| RequestedThemeVariant | Gets or sets the UI theme variant that is used by the control (and its child elements) for resource determination. The UI theme you specify with ThemeVariant can override the app-level ThemeVariant. Inherited from TopLevel. |
| Resources | Gets or sets the styled element's resource dictionary. Inherited from StyledElement. |
| Screens | Gets platform screens implementation. Inherited from WindowBase. |
| ShowActivated | Gets or sets a value that indicates whether a window is activated when first shown. |
| ShowInTaskbar | Enables or disables the taskbar icon |
| SizeToContent | Gets or sets a value indicating how the window will size itself to fit its content. |
| StorageProvider | File System storage service used for file pickers and bookmarks. Inherited from TopLevel. |
| StyleKey | Gets the type by which the element is styled. Inherited from StyledElement. |
| Styles | Gets the styles for the styled element. Inherited from StyledElement. |
| SystemDecorations | No summary available. |
| TabIndex | Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key. Inherited from InputElement. |
| Tag | Gets or sets a user-defined object attached to the control. Inherited from Control. |
| Template | Gets or sets the template that defines the control's appearance. Inherited from TemplatedControl. |
| TemplatedParent | Gets the styled element whose lookless template this styled element is part of. Inherited from StyledElement. |
| Theme | Gets or sets the theme to be applied to the element. Inherited from StyledElement. |
| Title | Gets or sets the title of the window. |
| Topmost | Gets or sets whether this window appears on top of all other windows Inherited from WindowBase. |
| Transitions | Gets or sets the property transitions for the control. Inherited from Animatable. |
| TransparencyBackgroundFallback | Gets or sets the Avalonia.Media.IBrush that transparency will blend with when transparency is not supported. By default this is a solid white brush. Inherited from TopLevel. |
| TransparencyLevelHint | Gets or sets the Avalonia.Controls.WindowTransparencyLevel that the TopLevel should use when possible. Accepts multiple values which are applied in a fallback order. For instance, with "Mica, Blur" Mica will be applied only on platforms where it is possible, and Blur will be used on the rest of them. Default value is an empty array or "None". Inherited from TopLevel. |
| UseLayoutRounding | Gets or sets a value that determines whether the element should be snapped to pixel boundaries at layout time. Inherited from Layoutable. |
| VerticalAlignment | Gets or sets the element's preferred vertical alignment in its parent. Inherited from Layoutable. |
| VerticalContentAlignment | Gets or sets the vertical alignment of the content within the control. Inherited from ContentControl. |
| Width | Gets or sets the width of the element. Inherited from Layoutable. |
| WindowDecorationMargin | Gets the WindowDecorationMargin. This tells you the thickness around the window that is used by borders and the titlebar. |
| WindowDecorations | Gets or sets the window decorations (title bar, border, etc). |
| WindowDecorationsTheme | Gets or sets the theme used to render the window decorations when they are not drawn by the system. |
| WindowStartupLocation | Gets or sets the startup location of the window. |
| WindowState | Represents the currently effective window state (normal, minimized, maximized) |
| ZIndex | Gets or sets the Z index of the control. Inherited from Visual. |
CanMaximize Property
Enables or disables maximizing the window.
public bool CanMaximize { get; set; }
Remarks
When Avalonia.Controls.Window.CanResize is false, this property is always false.
On macOS, setting this property to false also disables the full screen mode.
This property might be ignored by some window managers on Linux.
CanMinimize Property
Enables or disables minimizing the window.
public bool CanMinimize { get; set; }
Remarks
This property might be ignored by some window managers on Linux.
CanResize Property
Enables or disables resizing of the window.
public bool CanResize { get; set; }
ClosingBehavior Property
Gets or sets a value indicating how the Avalonia.Controls.Window.Closing event behaves in the presence of child windows.
public Avalonia.Controls.WindowClosingBehavior ClosingBehavior { get; set; }
ExtendClientAreaTitleBarHeightHint Property
Gets or Sets the TitlebarHeightHint for when the client area is extended. A value of -1 will cause the titlebar to be auto sized to the OS default. Any other positive value will cause the titlebar to assume that height.
public double ExtendClientAreaTitleBarHeightHint { get; set; }
ExtendClientAreaToDecorationsHint Property
Gets or sets if the ClientArea is Extended into the Window Decorations (chrome or border).
public bool ExtendClientAreaToDecorationsHint { get; set; }
Icon Property
Gets or sets the icon of the window.
public Avalonia.Controls.WindowIcon Icon { get; set; }
IsDialog Property
Gets whether this window was opened as a dialog
public bool IsDialog { get; set; }