Primary APIs:
AutomationPropertiesAccessibilityViewAutomationControlTypeAutomationLandmarkTypeAutomationLiveSettingIsOffscreenBehaviorImportant automation attached properties:
AutomationProperties.NameAutomationProperties.AutomationIdAutomationProperties.HelpTextAutomationProperties.LabeledByAutomationProperties.AccessKeyAutomationProperties.AcceleratorKeyAutomationProperties.ControlTypeOverrideAutomationProperties.LandmarkTypeAutomationProperties.HeadingLevelAutomationProperties.AccessibilityViewAutomationProperties.LiveSettingAutomationProperties.IsOffscreenBehaviorAutomationProperties.PositionInSetAutomationProperties.SizeOfSetRelated attached-behavior surfaces:
ToolTip.Tip, ToolTip.IsOpen, ToolTip.Placement, ToolTip.ShowDelay, ToolTip.BetweenShowDelay, ToolTip.ShowOnDisabled, ToolTip.ServiceEnabledRelativePanel attached layout relationships (Above, Below, LeftOf, RightOf, Align*With*)Reference source files:
src/Avalonia.Controls/Automation/AutomationProperties.cssrc/Avalonia.Controls/ToolTip.cssrc/Avalonia.Controls/RelativePanel.AttachedProperties.cssrc/Avalonia.Controls/RelativePanel.csAttach automation metadata directly in XAML:
<TextBox xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
AutomationProperties.Name="Email address"
AutomationProperties.AutomationId="Login_Email"
AutomationProperties.HelpText="Work email used for sign in" />
This metadata feeds automation peers used by accessibility tools and UI automation tests.
Use LabeledBy to connect labels and inputs explicitly:
<StackPanel xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Spacing="6">
<TextBlock x:Name="EmailLabel" Text="Email" />
<TextBox AutomationProperties.LabeledBy="{Binding #EmailLabel}"
AutomationProperties.AutomationId="Settings_Email" />
</StackPanel>
Landmark/heading pattern:
<TextBlock xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Text="Security"
AutomationProperties.LandmarkType="Main"
AutomationProperties.HeadingLevel="1" />
Use LiveSetting for status regions that need announcement behavior:
<TextBlock xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Text="Upload complete"
AutomationProperties.LiveSetting="Polite" />
For virtualization or overlays, set offscreen behavior intentionally:
<Border xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
AutomationProperties.IsOffscreenBehavior="FromClip" />
Note: some properties (IsColumnHeader, IsRequiredForForm, IsRowHeader, ItemStatus, ItemType, PositionInSet, SizeOfSet) are present for compatibility and may have limited or no effect in current implementations.
ToolTip behavior wiring:
<Button xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Content="Deploy"
ToolTip.Tip="Deploy current branch"
ToolTip.ShowDelay="200"
ToolTip.BetweenShowDelay="100"
ToolTip.ShowOnDisabled="True" />
Relative layout via attached properties:
<RelativePanel xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock x:Name="Title" Text="Dashboard" />
<Button Content="Refresh"
RelativePanel.RightOf="Title"
RelativePanel.AlignVerticalCenterWith="Title" />
</RelativePanel>
Use AvaloniaProperty.RegisterAttached<TOwner, THost, TValue> for reusable behavior metadata.
using Avalonia;
using Avalonia.Controls;
public static class ValidationHints
{
public static readonly AttachedProperty<string?> HintProperty =
AvaloniaProperty.RegisterAttached<ValidationHints, Control, string?>("Hint");
public static void SetHint(Control element, string? value) => element.SetValue(HintProperty, value);
public static string? GetHint(Control element) => element.GetValue(HintProperty);
}
This pattern mirrors built-in attached APIs like AutomationProperties.* and ToolTip.*.
using Avalonia;
using Avalonia.Automation;
using Avalonia.Controls;
void ApplyAutomationName(Control control, string name)
{
AutomationProperties.SetName(control, name);
}
string? ReadAutomationId(Control control)
{
return AutomationProperties.GetAutomationId(control);
}
void EnsureTooltip(Control control, string text)
{
ToolTip.SetTip(control, text);
ToolTip.SetShowDelay(control, 250);
}
AutomationId values for test automation targets.Name/HelpText that reflect user intent, not internal IDs.LabeledBy over duplicated label strings where possible.AutomationProperties.Name.AutomationProperties.AutomationId is set on the actual target element, not only containers.ToolTip.ServiceEnabled is true in the inheritance chain.LeftOf + AlignLeftWithPanel, etc.).AutomationProperties.LiveSetting is set and updates occur on the live element instance.