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
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".
Windows | UIA_AcceleratorKeyPropertyId |
macOS | No mapping |
GetAcceleratorKeyCore()
protected abstract string? GetAcceleratorKeyCore()
Returns
GetAccessKey()
Gets the access key for the element that is associated with the automation peer.
public string? GetAccessKey()
Returns
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.
Windows | UIA_AccessKeyPropertyId |
macOS | No mapping |
GetAccessKeyCore()
protected abstract string? GetAccessKeyCore()
Returns
GetAutomationControlType()
Gets the control type for the element that is associated with the UI Automation peer.
public AutomationControlType GetAutomationControlType()
Returns
Remarks
Gets the type of the element.
Windows | UIA_ControlTypePropertyId |
macOS | NSAccessibilityProtocol.accessibilityRole |
GetAutomationControlTypeCore()
protected abstract AutomationControlType GetAutomationControlTypeCore()
Returns
GetAutomationId()
Gets the automation ID of the element that is associated with the UI Automation peer.
public string? GetAutomationId()
Returns
Remarks
Windows |
UIA_AutomationIdPropertyId
|
macOS |
NSAccessibilityProtocol.accessibilityIdentifier
|
GetAutomationIdCore()
protected abstract string? GetAutomationIdCore()
Returns
GetBoundingRectangle()
Gets the bounding rectangle of the element that is associated with the automation peer in top-level coordinates.
public Rect GetBoundingRectangle()
Returns
Remarks
Windows |
IRawElementProviderFragment.get_BoundingRectangle
|
macOS |
NSAccessibilityProtocol.accessibilityFrame
|
GetBoundingRectangleCore()
protected abstract Rect GetBoundingRectangleCore()
Returns
GetChildren()
Gets the child automation peers.
public IReadOnlyList<AutomationPeer> GetChildren()
Returns
Remarks
Windows |
IRawElementProviderFragment.Navigate
|
macOS |
NSAccessibilityProtocol.accessibilityChildren
|
GetClassName()
Gets a string that describes the class of the element.
public string GetClassName()
Returns
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.
Windows | UIA_ClassNamePropertyId |
macOS | No mapping. |
GetClassNameCore()
protected abstract string GetClassNameCore()
Returns
GetControlTypeOverrideCore()
protected virtual AutomationControlType GetControlTypeOverrideCore()
Returns
GetHelpText()
Gets text that provides help for the element that is associated with this automation peer.
public string GetHelpText()
Returns
Remarks
Windows |
UIA_HelpTextPropertyId
|
macOS |
NSAccessibilityProtocol.accessibilityHelp
|
GetHelpTextCore()
protected virtual string? GetHelpTextCore()
Returns
GetLabeledBy()
Gets the automation peer for the label that is targeted to the element.
public AutomationPeer? GetLabeledBy()
Returns
Remarks
Identifies an automation peer representing an element which that contains the text label for this element.
Windows | UIA_LabeledByPropertyId (not yet implemented) |
macOS | NSAccessibilityProtocol.accessibilityLabelUIElements (not yet implemented) |
GetLabeledByCore()
protected abstract AutomationPeer? GetLabeledByCore()
Returns
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
Remarks
Windows |
UIA_LocalizedControlTypePropertyId (not yet implemented) |
macOS | No mapping. |
GetLocalizedControlTypeCore()
protected virtual string GetLocalizedControlTypeCore()
Returns
GetName()
Gets text that describes the element that is associated with this automation peer.
public string GetName()
Returns
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
GetOrCreateChildrenCore()
protected abstract IReadOnlyList<AutomationPeer> GetOrCreateChildrenCore()
Returns
GetParent()
Gets the AutomationPeer that is the parent of this AutomationPeer.
public AutomationPeer? GetParent()
Returns
Remarks
Windows |
IRawElementProviderFragment.Navigate
|
macOS |
NSAccessibilityProtocol.accessibilityParent
|
GetParentCore()
protected abstract AutomationPeer? GetParentCore()
Returns
GetProviderCore(Type)
protected virtual object? GetProviderCore(Type providerType)
Parameters
providerType
Type
Returns
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
Remarks
Windows | No mapping, but used internally to translate coordinates. |
macOS |
NSAccessibilityProtocol.accessibilityTopLevelUIElement
|
GetVisualRootCore()
protected virtual AutomationPeer? GetVisualRootCore()
Returns
HasKeyboardFocus()
Gets a value that indicates whether the element that is associated with this automation peer currently has keyboard focus.
public bool HasKeyboardFocus()
Returns
Remarks
Windows |
UIA_HasKeyboardFocusPropertyId
|
macOS |
NSAccessibilityProtocol.isAccessibilityFocused
|
HasKeyboardFocusCore()
protected abstract bool HasKeyboardFocusCore()
Returns
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
Remarks
Windows |
UIA_IsContentElementPropertyId
|
macOS | No mapping. |
IsContentElementCore()
protected abstract bool IsContentElementCore()
Returns
IsContentElementOverrideCore()
protected virtual bool IsContentElementOverrideCore()
Returns
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
Remarks
Windows |
UIA_IsControlElementPropertyId
|
macOS |
NSAccessibilityProtocol.isAccessibilityElement
|
IsControlElementCore()
protected abstract bool IsControlElementCore()
Returns
IsControlElementOverrideCore()
protected virtual bool IsControlElementOverrideCore()
Returns
IsEnabled()
Gets a value indicating whether the control is enabled for user interaction.
public bool IsEnabled()
Returns
Remarks
Windows |
UIA_IsEnabledPropertyId
|
macOS |
NSAccessibilityProtocol.isAccessibilityEnabled
|
IsEnabledCore()
protected abstract bool IsEnabledCore()
Returns
IsKeyboardFocusable()
Gets a value that indicates whether the element can accept keyboard focus.
public bool IsKeyboardFocusable()
Returns
Remarks
Windows |
UIA_IsKeyboardFocusablePropertyId
|
macOS | No mapping. |
IsKeyboardFocusableCore()
protected abstract bool IsKeyboardFocusableCore()
Returns
IsOffscreen()
Gets a value that indicates whether an element is off the screen.
public bool IsOffscreen()
Returns
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.
Windows | UIA_IsOffscreenPropertyId |
macOS | No mapping. |
IsOffscreenCore()
protected virtual bool IsOffscreenCore()
Returns
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
AutomationPropertyThe property that changed.
oldValue
objectThe previous value of the property.
newValue
objectThe 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
TrySetParent(AutomationPeer?)
protected abstract bool TrySetParent(AutomationPeer? parent)
Parameters
parent
AutomationPeer
Returns
Events
ChildrenChanged
Occurs when the children of the automation peer have changed.
public event EventHandler? ChildrenChanged
Event Type
PropertyChanged
Occurs when a property value of the automation peer has changed.
public event EventHandler<AutomationPropertyChangedEventArgs>? PropertyChanged