Table of Contents

Class AutomationPeer

Namespace
Avalonia.Automation.Peers
Assembly
Avalonia.Controls.dll

Provides a base class that exposes an element to UI Automation.

public abstract class AutomationPeer
Inheritance
AutomationPeer
Derived
Inherited Members

Constructors

AutomationPeer()

protected AutomationPeer()

Methods

BringIntoView()

Attempts to bring the element associated with the automation peer into view.

public void BringIntoView()

BringIntoViewCore()

protected abstract void BringIntoViewCore()

EnsureEnabled()

protected void EnsureEnabled()

GetAcceleratorKey()

Gets the accelerator key combinations for the element that is associated with the UI Automation peer.

public string? GetAcceleratorKey()

Returns

string

Remarks

An accelerator key (sometimes called a shortcut key) exposes a key combination for which can be used to invoke an action, for example, an "Open..." menu item on Windows often has an accelerator key of "Ctrl+O".

WindowsUIA_AcceleratorKeyPropertyId
macOSNo mapping

GetAcceleratorKeyCore()

protected abstract string? GetAcceleratorKeyCore()

Returns

string

GetAccessKey()

Gets the access key for the element that is associated with the automation peer.

public string? GetAccessKey()

Returns

string

Remarks

An access key (sometimes called a mnemonic) is a character in the text of a menu, menu item, or label of a control such as a button, that activates the associated function. For example, to open the File menu, for which the access key is typically F, the user would press ALT+F.

WindowsUIA_AccessKeyPropertyId
macOSNo mapping

GetAccessKeyCore()

protected abstract string? GetAccessKeyCore()

Returns

string

GetAutomationControlType()

Gets the control type for the element that is associated with the UI Automation peer.

public AutomationControlType GetAutomationControlType()

Returns

AutomationControlType

Remarks

Gets the type of the element.

WindowsUIA_ControlTypePropertyId
macOSNSAccessibilityProtocol.accessibilityRole

GetAutomationControlTypeCore()

protected abstract AutomationControlType GetAutomationControlTypeCore()

Returns

AutomationControlType

GetAutomationId()

Gets the automation ID of the element that is associated with the UI Automation peer.

public string? GetAutomationId()

Returns

string

Remarks

Windows UIA_AutomationIdPropertyId
macOS NSAccessibilityProtocol.accessibilityIdentifier

GetAutomationIdCore()

protected abstract string? GetAutomationIdCore()

Returns

string

GetBoundingRectangle()

Gets the bounding rectangle of the element that is associated with the automation peer in top-level coordinates.

public Rect GetBoundingRectangle()

Returns

Rect

Remarks

Windows IRawElementProviderFragment.get_BoundingRectangle
macOS NSAccessibilityProtocol.accessibilityFrame

GetBoundingRectangleCore()

protected abstract Rect GetBoundingRectangleCore()

Returns

Rect

GetChildren()

Gets the child automation peers.

public IReadOnlyList<AutomationPeer> GetChildren()

Returns

IReadOnlyList<AutomationPeer>

Remarks

Windows IRawElementProviderFragment.Navigate
macOS NSAccessibilityProtocol.accessibilityChildren

GetClassName()

Gets a string that describes the class of the element.

public string GetClassName()

Returns

string

Remarks

A string containing the class name for the automation element as assigned by the control developer. This is often the C# class name of the control.

WindowsUIA_ClassNamePropertyId
macOSNo mapping.

GetClassNameCore()

protected abstract string GetClassNameCore()

Returns

string

GetControlTypeOverrideCore()

protected virtual AutomationControlType GetControlTypeOverrideCore()

Returns

AutomationControlType

GetHelpText()

Gets text that provides help for the element that is associated with this automation peer.

public string GetHelpText()

Returns

string

Remarks

Windows UIA_HelpTextPropertyId
macOS NSAccessibilityProtocol.accessibilityHelp

GetHelpTextCore()

protected virtual string? GetHelpTextCore()

Returns

string

GetLabeledBy()

Gets the automation peer for the label that is targeted to the element.

public AutomationPeer? GetLabeledBy()

Returns

AutomationPeer

Remarks

Identifies an automation peer representing an element which that contains the text label for this element.

WindowsUIA_LabeledByPropertyId (not yet implemented)
macOSNSAccessibilityProtocol.accessibilityLabelUIElements (not yet implemented)

GetLabeledByCore()

protected abstract AutomationPeer? GetLabeledByCore()

Returns

AutomationPeer

GetLocalizedControlType()

Gets a human-readable localized string that represents the type of the control that is associated with this automation peer.

public string GetLocalizedControlType()

Returns

string

Remarks

Windows UIA_LocalizedControlTypePropertyId (not yet implemented)
macOSNo mapping.

GetLocalizedControlTypeCore()

protected virtual string GetLocalizedControlTypeCore()

Returns

string

GetName()

Gets text that describes the element that is associated with this automation peer.

public string GetName()

Returns

string

Remarks

Windows UIA_NamePropertyId (not yet implemented)
macOS When the control type is Text, this value is exposed by both NSAccessibilityProtocol.accessibilityTitle and NSAccessibilityProtocol.accessibilityValue .

GetNameCore()

protected abstract string? GetNameCore()

Returns

string

GetOrCreateChildrenCore()

protected abstract IReadOnlyList<AutomationPeer> GetOrCreateChildrenCore()

Returns

IReadOnlyList<AutomationPeer>

GetParent()

Gets the AutomationPeer that is the parent of this AutomationPeer.

public AutomationPeer? GetParent()

Returns

AutomationPeer

Remarks

Windows IRawElementProviderFragment.Navigate
macOS NSAccessibilityProtocol.accessibilityParent

GetParentCore()

protected abstract AutomationPeer? GetParentCore()

Returns

AutomationPeer

GetProviderCore(Type)

protected virtual object? GetProviderCore(Type providerType)

Parameters

providerType Type

Returns

object

GetProvider<T>()

Tries to get a provider of the specified type from the peer.

public T? GetProvider<T>()

Returns

T

The provider, or null if not implemented on this peer.

Type Parameters

T

The provider type.

GetVisualRoot()

Gets the AutomationPeer that is the root of this AutomationPeer's visual tree.

public AutomationPeer? GetVisualRoot()

Returns

AutomationPeer

Remarks

WindowsNo mapping, but used internally to translate coordinates.
macOS NSAccessibilityProtocol.accessibilityTopLevelUIElement

GetVisualRootCore()

protected virtual AutomationPeer? GetVisualRootCore()

Returns

AutomationPeer

HasKeyboardFocus()

Gets a value that indicates whether the element that is associated with this automation peer currently has keyboard focus.

public bool HasKeyboardFocus()

Returns

bool

Remarks

Windows UIA_HasKeyboardFocusPropertyId
macOS NSAccessibilityProtocol.isAccessibilityFocused

HasKeyboardFocusCore()

protected abstract bool HasKeyboardFocusCore()

Returns

bool

IsContentElement()

Gets a value that indicates whether the element that is associated with this automation peer contains data that is presented to the user.

public bool IsContentElement()

Returns

bool

Remarks

Windows UIA_IsContentElementPropertyId
macOSNo mapping.

IsContentElementCore()

protected abstract bool IsContentElementCore()

Returns

bool

IsContentElementOverrideCore()

protected virtual bool IsContentElementOverrideCore()

Returns

bool

IsControlElement()

Gets a value that indicates whether the element is understood by the user as interactive or as contributing to the logical structure of the control in the GUI.

public bool IsControlElement()

Returns

bool

Remarks

Windows UIA_IsControlElementPropertyId
macOS NSAccessibilityProtocol.isAccessibilityElement

IsControlElementCore()

protected abstract bool IsControlElementCore()

Returns

bool

IsControlElementOverrideCore()

protected virtual bool IsControlElementOverrideCore()

Returns

bool

IsEnabled()

Gets a value indicating whether the control is enabled for user interaction.

public bool IsEnabled()

Returns

bool

Remarks

Windows UIA_IsEnabledPropertyId
macOS NSAccessibilityProtocol.isAccessibilityEnabled

IsEnabledCore()

protected abstract bool IsEnabledCore()

Returns

bool

IsKeyboardFocusable()

Gets a value that indicates whether the element can accept keyboard focus.

public bool IsKeyboardFocusable()

Returns

bool

Remarks

Windows UIA_IsKeyboardFocusablePropertyId
macOSNo mapping.

IsKeyboardFocusableCore()

protected abstract bool IsKeyboardFocusableCore()

Returns

bool

IsOffscreen()

Gets a value that indicates whether an element is off the screen.

public bool IsOffscreen()

Returns

bool

Remarks

This property does not indicate whether the element is visible. In some circumstances, an element is on the screen but is still not visible. For example, if the element is on the screen but obscured by other elements, it might not be visible. In this case, the method returns false.

WindowsUIA_IsOffscreenPropertyId
macOSNo mapping.

IsOffscreenCore()

protected virtual bool IsOffscreenCore()

Returns

bool

RaiseChildrenChangedEvent()

Raises an event to notify the automation client the children of the peer have changed.

protected void RaiseChildrenChangedEvent()

RaisePropertyChangedEvent(AutomationProperty, object?, object?)

Raises an event to notify the automation client of a changed property value.

public void RaisePropertyChangedEvent(AutomationProperty property, object? oldValue, object? newValue)

Parameters

property AutomationProperty

The property that changed.

oldValue object

The previous value of the property.

newValue object

The new value of the property.

SetFocus()

Sets the keyboard focus on the element that is associated with this automation peer.

public void SetFocus()

SetFocusCore()

protected abstract void SetFocusCore()

ShowContextMenu()

Shows the context menu for the element that is associated with this automation peer.

public bool ShowContextMenu()

Returns

bool

true if a context menu is present for the element; otherwise false.

ShowContextMenuCore()

protected abstract bool ShowContextMenuCore()

Returns

bool

TrySetParent(AutomationPeer?)

protected abstract bool TrySetParent(AutomationPeer? parent)

Parameters

parent AutomationPeer

Returns

bool

Events

ChildrenChanged

Occurs when the children of the automation peer have changed.

public event EventHandler? ChildrenChanged

Event Type

EventHandler

PropertyChanged

Occurs when a property value of the automation peer has changed.

public event EventHandler<AutomationPropertyChangedEventArgs>? PropertyChanged

Event Type

EventHandler<AutomationPropertyChangedEventArgs>