In This Article

WindowTitleBar Class

Provides an implementation of ChromedTitleBar that is integrated with its ancestor Window control.

public class WindowTitleBar : ChromedTitleBar, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance:
object AvaloniaObject Animatable StyledElement Visual Layoutable Interactive InputElement Control TemplatedControl ContentControl ChromedTitleBar object
Implements:
IDataContextProvider ILogical IThemeVariantHost IResourceHost IResourceNode IStyleHost ISetLogicalParent ISetInheritanceParent IStyleable INamed IInputElement IDataTemplateHost ISetterValue

Constructors

WindowTitleBar()

Initializes an instance of the class.

public WindowTitleBar()

Properties

CanConfigureWindowClientArea

Indicates if the containing window's client area extension properties can be configured.

public bool CanConfigureWindowClientArea { get; set; }

Property Value

bool:

The default value is true.

Remarks

This property determines if the Avalonia.Controls.Window.ExtendClientAreaChromeHints, Avalonia.Controls.Window.ExtendClientAreaToDecorationsHint, and Avalonia.Controls.Window.ExtendClientAreaTitleBarHeightHint properties are set. This property must be set prior to the title bar control being added to the visual tree, or its value will have no effect.

CanDrag

Indicates if the Avalonia.Input.InputElement.PointerPressed event on this control is allowed to initiate a move drag on the parent Window.

public bool CanDrag { get; set; }

Property Value

bool:

The default value is true.

Remarks

This property only detects when the pointer is pressed on the title bar control and does not affect pointer pressed events that are directly received by the parent Window.

IsAttachedToWindow

Indicates if the titlebar is currently attached to a Window.

public bool IsAttachedToWindow { get; }

Property Value

bool

IsPrimary

Indicates if the titlebar is the primary titlebar for the attached Window.

public bool IsPrimary { get; }

Property Value

bool

Window

The Window, if any, that is currently attached to the titlebar.

public Window? Window { get; }

Property Value

Window

Methods

ArrangeOverride(Size)

Positions child elements as part of a layout pass.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The size available to the control.

Returns

Size:

The actual size used.

OnApplyTemplate(TemplateAppliedEventArgs)

Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameter Type Description
e TemplateAppliedEventArgs

The event args.

OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is added to a rooted visual tree.

protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameter Type Description
e VisualTreeAttachmentEventArgs

The event args.

OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is removed from a rooted visual tree.

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
Parameter Type Description
e VisualTreeAttachmentEventArgs

The event args.

OnPointerPressed(PointerPressedEventArgs)

Called before the Avalonia.Input.InputElement.PointerPressed event occurs.

protected override void OnPointerPressed(PointerPressedEventArgs e)
Parameter Type Description
e PointerPressedEventArgs

The event args.

QueryHasCaptionButtons()

Queries the value to be assigned to HasCaptionButtons based on the current state.

protected override bool QueryHasCaptionButtons()

Returns

bool

Fields

CanConfigureWindowClientAreaProperty

Defines the CanConfigureWindowClientArea property.

public static readonly StyledProperty<bool> CanConfigureWindowClientAreaProperty

CanDragProperty

Defines the CanDrag property.

public static readonly StyledProperty<bool> CanDragProperty

IsAttachedToWindowProperty

Defines the IsAttachedToWindow property.

public static readonly DirectProperty<WindowTitleBar, bool> IsAttachedToWindowProperty

IsPrimaryProperty

Defines the IsPrimary property.

public static readonly DirectProperty<WindowTitleBar, bool> IsPrimaryProperty

WindowProperty

Defines the Window property.

public static readonly DirectProperty<WindowTitleBar, Window?> WindowProperty

Inherited Members

Extension Methods