In This Article

ToolWindow Class

Represents a tool window.

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

Constructors

ToolWindow()

Initializes an instance of the class.

public ToolWindow()

ToolWindow(DockSite?, string?, string?, object?, object?)

Initializes an instance of the class.

public ToolWindow(DockSite? dockSite, string? serializationId = null, string? title = null, object? icon = null, object? content = null)
Parameter Type Description
dockSite DockSite

The DockSite with which to register this window.

serializationId string

The serialization ID of the window, used during layout serialization.

title string

The title of the window.

icon object

The object that defines the window's icon.

content object

The content of the window.

ToolWindow(bool)

Initializes an instance of the class.

public ToolWindow(bool isContainerForItem)
Parameter Type Description
isContainerForItem bool

Whether the window is a container for an item.

Properties

AutoHideCommand

The ICommand that can move the window into an auto-hide state.

public ICommand AutoHideCommand { get; }

Property Value

ICommand

AutoHideTabContextContentTemplate

The Avalonia.Controls.Templates.IDataTemplate containing contextual content that should be rendered in an auto-hide tab for this window.

public IDataTemplate? AutoHideTabContextContentTemplate { get; set; }

Property Value

IDataTemplate

CanAutoHide

Indicates whether the tool window may be placed in auto-hide mode.

public bool? CanAutoHide { get; set; }

Property Value

bool?

Remarks

If set to null, the resolved value will use the global DockSite setting.

CanAutoHideResolved

A resolved value indicating whether the tool window may be placed in auto-hide mode.

public bool CanAutoHideResolved { get; }

Property Value

bool:

true if the tool window may be placed in auto-hide mode; otherwise, false.

CanBecomeDocument

Indicates whether the tool window may be placed in a document state.

public bool? CanBecomeDocument { get; set; }

Property Value

bool?

Remarks

If set to null, the resolved value will use the global DockSite setting.

ContainerAutoHideSize

The Avalonia.Size of the tool window's container when it is in an auto-hide state.

public Size ContainerAutoHideSize { get; set; }

Property Value

Size

Remarks

The container is a ToolWindowContainer.

DefaultDockSide

The default dock side that the tool window will dock towards when no prior location is known.

public Dock DefaultDockSide { get; set; }

Property Value

Dock:

The default value is Avalonia.Controls.Dock.Right.

DockCommand

The ICommand that can move the window into a docked state.

public ICommand DockCommand { get; }

Property Value

ICommand

HasOptionsButton

Indicates whether the tool window displays an options button in its ToolWindowContainer title bar.

public bool? HasOptionsButton { get; set; }

Property Value

bool?

Remarks

If set to null, the resolved value will use the global DockSite setting. If this value resolves to true then the window will display a drop-down menu button.

HasOptionsButtonResolved

A resolved value indicating whether the tool window displays an options button in its ToolWindowContainer title bar.

public bool HasOptionsButtonResolved { get; }

Property Value

bool:

true if the tool window displays an options button in its ToolWindowContainer title bar; otherwise, false.

HasTitleBar

Indicates whether the tool window displays a title bar in its parent ToolWindowContainer.

public bool? HasTitleBar { get; set; }

Property Value

bool?

Remarks

If set to null, the resolved value will use the global DockSite setting.

HasTitleBarResolved

A resolved value indicating whether the tool window displays a title bar in its parent ToolWindowContainer.

public bool HasTitleBarResolved { get; }

Property Value

bool:

true if the tool window displays a title bar in its parent ToolWindowContainer; otherwise, false.

IsAutoHidePopupOpen

Indicates whether the tool window is currently visible within an auto-hide popup.

public bool IsAutoHidePopupOpen { get; }

Property Value

bool:

The default value is false.

Remarks

This property is only true when the tool window is an auto-hide State and it is the AutoHidePopupToolWindow in the containing dock host.

ToolWindowContainerTabContextContentTemplate

The Avalonia.Controls.Templates.IDataTemplate containing contextual content that should be rendered in a tool window container's tab for this tool window.

public IDataTemplate? ToolWindowContainerTabContextContentTemplate { get; set; }

Property Value

IDataTemplate

ToolWindowContainerTitleBarContextContentTemplate

The Avalonia.Controls.Templates.IDataTemplate containing contextual content that should be rendered in a tool window container's title bar when this tool window is active.

public IDataTemplate? ToolWindowContainerTitleBarContextContentTemplate { get; set; }

Property Value

IDataTemplate

Methods

Attach(IDockTarget)

Attaches the ToolWindow to the specified target, generally making a tabbed group.

public void Attach(IDockTarget target)
Parameter Type Description
target IDockTarget

The IDockTarget against which to attach.

Remarks

The target can be another docking window, TabbedMdiContainer, or ToolWindowContainer. Use the Dock(IDockTarget, Dock) method to dock to the side of the target instead.

AutoHide()

Auto-hides the ToolWindow to the closest outer-edge of the ancestor DockHost.

public void AutoHide()

Remarks

Using this method places the ToolWindow in an AutoHideState. Use the AutoHide(Dock) method overload to auto-hide to a specific side.

AutoHide(Dock)

Auto-hides the ToolWindow to the specified outer-edge of the ancestor DockHost.

public void AutoHide(Dock side)
Parameter Type Description
side Dock

A dock side indicating the side upon which to auto-hide.

Remarks

Using this method places the ToolWindow in an AutoHideState. Use the AutoHide() method overload to auto-hide to the control's default side.

Dock()

Docks the ToolWindow back to its default docked location.

public void Dock()

Remarks

Using this method places the ToolWindow in a DockedState. If the tool window isn't currently open or isn't in a Docked state, it will attempt to restore to the previous docked location. If one isn't available, a default docked location will be selected based on WindowGroupName, DefaultLocationRequested, and DefaultDockSide.

Dock(IDockTarget, Dock)

Docks the ToolWindow to the side of a specified target.

public void Dock(IDockTarget target, Dock side)
Parameter Type Description
target IDockTarget

The IDockTarget that is the target of the dock.

side Dock

The target's side against which to dock.

Remarks

Use the Dock() method overload to dock back to its previous docked location. Use the Attach(IDockTarget) method to dock into a particular target.

Float(Point?, Size?)

Floats the window to the specified optional location and size.

public override void Float(Point? location, Size? size)
Parameter Type Description
location Point?

An optional Avalonia.Point specifying the target location of the floating dock host.

When UseHostedFloatingWindows is true, the location is expressed relative to the containing control; otherwise, the value is the location in screen coordinates.

size Size?

An optional Avalonia.Size specifying the target size of the floating dock host.

Remarks

When location is not specified, it will float to a default location. When size is not specified, it will float with its current size.

GetCurrentSide()

Returns a dock side indicating where the tool window is located, if it is currently open.

public Dock? GetCurrentSide()

Returns

Dock?

Remarks

If the tool window is open in a Document state, null is returned. If the tool window is open in an AutoHide state, the auto-hide dock side is returned. If the tool window is open in a Docked state and the containing dock host has a workspace (no tool window inner-fill), a dock side indicating the location of the tool window relative to the workspace is returned. If the tool window is open in a Docked state and the containing dock host does not have a workspace (tool window inner-fill is active), a dock side indicating the location of the tool window's midpoint relative to the dock host's bounds is returned. Otherwise, if the tool window is closed, null is returned.

OnCreateAutomationPeer()

Returns a new, type-specific Avalonia.Automation.Peers.AutomationPeer implementation for the control.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific Avalonia.Automation.Peers.AutomationPeer implementation.

OnDockSiteChanged(DockSite?, DockSite?)

Occurs when the value of the DockSite property has changed.

protected override void OnDockSiteChanged(DockSite? oldValue, DockSite? newValue)
Parameter Type Description
oldValue DockSite

The old value.

newValue DockSite

The new value.

OnStateChanged(DockingWindowState, DockingWindowState)

Occurs when the value of the State property has changed.

protected override void OnStateChanged(DockingWindowState oldValue, DockingWindowState newValue)
Parameter Type Description
oldValue DockingWindowState

The old value.

newValue DockingWindowState

The new value.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

UpdateCanAttachResolved()

Updates the CanAttachResolved value.

protected override void UpdateCanAttachResolved()

UpdateCanBecomeDocumentResolved()

Updates the CanBecomeDocumentResolved value.

protected override void UpdateCanBecomeDocumentResolved()

UpdateCanCloseResolved()

Updates the CanCloseResolved value.

protected override void UpdateCanCloseResolved()

UpdateCanDockResolved()

Updates the CanDockResolved value.

protected override void UpdateCanDockResolved()

UpdateCanDragTabResolved()

Updates the CanDragTabResolved value.

protected override void UpdateCanDragTabResolved()

UpdateCanDragToLinkedDockSitesResolved()

protected override void UpdateCanDragToLinkedDockSitesResolved()

UpdateCanFloatResolved()

Updates the CanFloatResolved value.

protected override void UpdateCanFloatResolved()

UpdateCommands()

Updates the enabled states of the commands.

protected override void UpdateCommands()

Fields

AutoHideTabContextContentTemplateProperty

Defines the AutoHideTabContextContentTemplate property.

public static readonly StyledProperty<IDataTemplate?> AutoHideTabContextContentTemplateProperty

CanAutoHideProperty

Defines the CanAutoHide property.

public static readonly StyledProperty<bool?> CanAutoHideProperty

CanAutoHideResolvedProperty

Defines the CanAutoHideResolved property.

public static readonly StyledProperty<bool> CanAutoHideResolvedProperty

CanBecomeDocumentProperty

Defines the CanBecomeDocument property.

public static readonly StyledProperty<bool?> CanBecomeDocumentProperty

ContainerAutoHideSizeProperty

Defines the ContainerAutoHideSize property.

public static readonly StyledProperty<Size> ContainerAutoHideSizeProperty

DefaultDockSideProperty

Defines the DefaultDockSide property.

public static readonly StyledProperty<Dock> DefaultDockSideProperty

HasOptionsButtonProperty

Defines the HasOptionsButton property.

public static readonly StyledProperty<bool?> HasOptionsButtonProperty

HasOptionsButtonResolvedProperty

Defines the HasOptionsButtonResolved property.

public static readonly StyledProperty<bool> HasOptionsButtonResolvedProperty

HasTitleBarProperty

Defines the HasTitleBar property.

public static readonly StyledProperty<bool?> HasTitleBarProperty

HasTitleBarResolvedProperty

Defines the HasTitleBarResolved property.

public static readonly StyledProperty<bool> HasTitleBarResolvedProperty

IsAutoHidePopupOpenProperty

Defines the IsAutoHidePopupOpen property.

public static readonly StyledProperty<bool> IsAutoHidePopupOpenProperty

ToolWindowContainerTabContextContentTemplateProperty

public static readonly StyledProperty<IDataTemplate?> ToolWindowContainerTabContextContentTemplateProperty

ToolWindowContainerTitleBarContextContentTemplateProperty

public static readonly StyledProperty<IDataTemplate?> ToolWindowContainerTitleBarContextContentTemplateProperty

Inherited Members

Extension Methods