Skip to main content

AutomationPeer Class

Definition

Assembly:Avalonia.Controls
Package:Avalonia

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

public class AutomationPeer

Inheritance: object -> AutomationPeer

Methods

NameDescription
BringIntoViewAttempts to bring the element associated with the automation peer into view.
GetAcceleratorKeyGets the accelerator key combinations for the element that is associated with the UI Automation peer.
GetAccessKeyGets the access key for the element that is associated with the automation peer.
GetAutomationControlTypeGets the control type for the element that is associated with the UI Automation peer.
GetAutomationIdGets the automation ID of the element that is associated with the UI Automation peer.
GetBoundingRectangleGets the bounding rectangle of the element that is associated with the automation peer in top-level coordinates.
GetChildrenGets the child automation peers.
GetClassNameGets a string that describes the class of the element.
GetHeadingLevelGets the heading level that is associated with this automation peer.
GetHelpTextGets text that provides help for the element that is associated with this automation peer.
GetItemStatusGets the item status that is associated with this automation peer.
GetItemTypeGets the item type that is associated with this automation peer.
GetLabeledByGets the automation peer for the label that is targeted to the element.
GetLandmarkTypeGets the control type for the element that is associated with the UI Automation peer.
GetLiveSettingGets the current live setting that is associated with this this automation peer.
GetLocalizedControlTypeGets a human-readable localized string that represents the type of the control that is associated with this automation peer.
GetNameGets text that describes the element that is associated with this automation peer.
GetParentGets the Avalonia.Automation.Peers.AutomationPeer that is the parent of this Avalonia.Automation.Peers.AutomationPeer.
GetPlaceholderTextGets text that provides a placeholder for the element that is associated with this automation peer.
GetProviderNo summary available.
HasKeyboardFocusGets a value that indicates whether the element that is associated with this automation peer currently has keyboard focus.
IsContentElementGets a value that indicates whether the element that is associated with this automation peer contains data that is presented to the user.
IsControlElementGets 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.
IsEnabledGets a value indicating whether the control is enabled for user interaction.
IsKeyboardFocusableGets a value that indicates whether the element can accept keyboard focus.
IsOffscreenGets a value that indicates whether an element is off the screen.
RaisePropertyChangedEventRaises an event to notify the automation client of a changed property value.
SetFocusSets the keyboard focus on the element that is associated with this automation peer.
ShowContextMenuShows the context menu for the element that is associated with this automation peer.

BringIntoView Method

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

public void BringIntoView()

GetAcceleratorKey Method

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

GetAccessKey Method

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

GetAutomationControlType Method

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

public Avalonia.Automation.Peers.AutomationControlType GetAutomationControlType()

Returns

Avalonia.Automation.Peers.AutomationControlType

Remarks

Gets the type of the element.

  • WindowsUIA_ControlTypePropertyId
  • macOSNSAccessibilityProtocol.accessibilityRole

GetAutomationId Method

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

public string GetAutomationId()

Returns

string

Remarks

  • WindowsUIA_AutomationIdPropertyId
  • macOSNSAccessibilityProtocol.accessibilityIdentifier

GetBoundingRectangle Method

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

public Avalonia.Rect GetBoundingRectangle()

Returns

Avalonia.Rect

Remarks

  • WindowsIRawElementProviderFragment.get_BoundingRectangle
  • macOSNSAccessibilityProtocol.accessibilityFrame

GetChildren Method

Gets the child automation peers.

public System.Collections.Generic.IReadOnlyList<Avalonia.Automation.Peers.AutomationPeer> GetChildren()

Returns

System.Collections.Generic.IReadOnlyList<Avalonia.Automation.Peers.AutomationPeer>

Remarks

  • WindowsIRawElementProviderFragment.Navigate
  • macOSNSAccessibilityProtocol.accessibilityChildren

GetClassName Method

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.

GetHeadingLevel Method

Gets the heading level that is associated with this automation peer.

public int GetHeadingLevel()

Returns

int

Remarks

  • WindowsUIA_HeadingLevelPropertyId
  • macOSNSAccessibilityProtocol.accessibilityValue

GetHelpText Method

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

public string GetHelpText()

Returns

string

Remarks

  • WindowsUIA_HelpTextPropertyId
  • macOSNSAccessibilityProtocol.accessibilityHelp

GetItemStatus Method

Gets the item status that is associated with this automation peer.

public string GetItemStatus()

Returns

string

Remarks

  • WindowsUIA_ItemStatusPropertyId
  • macOSNo mapping.

GetItemType Method

Gets the item type that is associated with this automation peer.

public string GetItemType()

Returns

string

Remarks

  • WindowsUIA_ItemTypePropertyId
  • macOSNo mapping.

GetLabeledBy Method

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

public Avalonia.Automation.Peers.AutomationPeer GetLabeledBy()

Returns

Avalonia.Automation.Peers.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)

GetLandmarkType Method

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

public Nullable<Avalonia.Automation.Peers.AutomationLandmarkType> GetLandmarkType()

Returns

Nullable<Avalonia.Automation.Peers.AutomationLandmarkType>

Remarks

Gets the type of the element.

  • WindowsUIA_LandmarkTypePropertyId, UIA_LocalizedLandmarkTypePropertyId
  • macOSNSAccessibilityProtocol.accessibilityRole, NSAccessibilityProtocol.accessibilitySubrole

GetLiveSetting Method

Gets the current live setting that is associated with this this automation peer.

public Avalonia.Automation.AutomationLiveSetting GetLiveSetting()

Returns

Avalonia.Automation.AutomationLiveSetting

The live setting to use for automation.

GetLocalizedControlType Method

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

  • WindowsUIA_LocalizedControlTypePropertyId (not yet implemented)
  • macOSNo mapping.

GetName Method

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

public string GetName()

Returns

string

Remarks

GetParent Method

Gets the Avalonia.Automation.Peers.AutomationPeer that is the parent of this Avalonia.Automation.Peers.AutomationPeer.

public Avalonia.Automation.Peers.AutomationPeer GetParent()

Returns

Avalonia.Automation.Peers.AutomationPeer

Remarks

  • WindowsIRawElementProviderFragment.Navigate
  • macOSNSAccessibilityProtocol.accessibilityParent

GetPlaceholderText Method

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

public string GetPlaceholderText()

Returns

string

Remarks

  • WindowsNo mapping.
  • macOSNSAccessibilityProtocol.accessibilityPlaceholderValue

GetProvider Method

public T GetProvider<T>()

Type Parameters

T

Returns

T

HasKeyboardFocus Method

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

  • WindowsUIA_HasKeyboardFocusPropertyId
  • macOSNSAccessibilityProtocol.isAccessibilityFocused

IsContentElement Method

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

  • WindowsUIA_IsContentElementPropertyId
  • macOSNo mapping.

IsControlElement Method

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

  • WindowsUIA_IsControlElementPropertyId
  • macOSNSAccessibilityProtocol.isAccessibilityElement

IsEnabled Method

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

public bool IsEnabled()

Returns

bool

Remarks

  • WindowsUIA_IsEnabledPropertyId
  • macOSNSAccessibilityProtocol.isAccessibilityEnabled

IsKeyboardFocusable Method

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

public bool IsKeyboardFocusable()

Returns

bool

Remarks

  • WindowsUIA_IsKeyboardFocusablePropertyId
  • macOSNo mapping.

IsOffscreen Method

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.

RaisePropertyChangedEvent Method

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

public void RaisePropertyChangedEvent(Avalonia.Automation.AutomationProperty property, object oldValue, object newValue)

Parameters

property Avalonia.Automation.AutomationProperty

The property that changed.

oldValue object

The previous value of the property.

newValue object

The new value of the property.

SetFocus Method

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

public void SetFocus()

ShowContextMenu Method

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.

Events

NameDescription
ChildrenChangedOccurs when the children of the automation peer have changed.
PropertyChangedOccurs when a property value of the automation peer has changed.

ChildrenChanged Event

Occurs when the children of the automation peer have changed.

public event EventHandler ChildrenChanged

PropertyChanged Event

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

public event EventHandler<Avalonia.Automation.AutomationPropertyChangedEventArgs> PropertyChanged