ItemStatus and ItemType UIA properties (#20669)

* ItemStatus and ItemType UIA properties

* ItemStatus property change notification

---------

Co-authored-by: Jan Kučera <miloush@users.noreply.github.com>
This commit is contained in:
Jan Kučera
2026-02-11 16:59:20 +00:00
committed by GitHub
parent a48c415026
commit 79239b5842
4 changed files with 55 additions and 0 deletions
@@ -31,6 +31,12 @@ namespace Avalonia.Automation
/// </summary>
public static AutomationProperty HelpTextProperty { get; } = new AutomationProperty();
/// <summary>
/// Identifies the itemStatus automation property. The class name property value is returned
/// by the <see cref="AutomationPeer.GetItemStatus"/> method.
/// </summary>
public static AutomationProperty ItemStatusProperty { get; } = new AutomationProperty();
/// <summary>
/// Identifies the landmark type automation property. The class name property value is returned
/// by the <see cref="AutomationPeer.GetLandmarkType"/> method.
@@ -319,6 +319,41 @@ namespace Avalonia.Automation.Peers
/// </remarks>
public int GetHeadingLevel() => GetHeadingLevelCore();
/// <summary>
/// Gets the item type that is associated with this automation peer.
/// </summary>
/// <remarks>
/// <list type="table">
/// <item>
/// <term>Windows</term>
/// <description><c>UIA_ItemTypePropertyId</c></description>
/// </item>
/// <item>
/// <term>macOS</term>
/// <description>No mapping.</description>
/// </item>
/// </list>
/// </remarks>
public string? GetItemType() => GetItemTypeCore();
/// <summary>
/// Gets the item status that is associated with this automation peer.
/// </summary>
/// <remarks>
/// <list type="table">
/// <item>
/// <term>Windows</term>
/// <description><c>UIA_ItemStatusPropertyId</c></description>
/// </item>
/// <item>
/// <term>macOS</term>
/// <description>No mapping.</description>
/// </item>
/// </list>
/// </remarks>
public string? GetItemStatus() => GetItemStatusCore();
/// <summary>
/// Gets the <see cref="AutomationPeer"/> that is the parent of this <see cref="AutomationPeer"/>.
/// </summary>
@@ -562,6 +597,8 @@ namespace Avalonia.Automation.Peers
protected virtual string? GetHelpTextCore() => null;
protected virtual AutomationLandmarkType? GetLandmarkTypeCore() => null;
protected virtual int GetHeadingLevelCore() => 0;
protected virtual string? GetItemTypeCore() => null;
protected virtual string? GetItemStatusCore() => null;
protected abstract AutomationPeer? GetParentCore();
protected abstract bool HasKeyboardFocusCore();
protected abstract bool IsContentElementCore();
@@ -199,6 +199,8 @@ namespace Avalonia.Automation.Peers
protected override string? GetAutomationIdCore() => AutomationProperties.GetAutomationId(Owner) ?? Owner.Name;
protected override Rect GetBoundingRectangleCore() => GetBounds(Owner);
protected override string GetClassNameCore() => Owner.GetType().Name;
protected override string? GetItemStatusCore() => AutomationProperties.GetItemStatus(Owner);
protected override string? GetItemTypeCore() => AutomationProperties.GetItemType(Owner);
protected override bool HasKeyboardFocusCore() => Owner.IsFocused;
protected override bool IsContentElementCore() => true;
protected override bool IsControlElementCore() => true;
@@ -281,6 +283,13 @@ namespace Avalonia.Automation.Peers
{
InvalidateParent();
}
else if (e.Property == AutomationProperties.ItemStatusProperty)
{
RaisePropertyChangedEvent(
AutomationElementIdentifiers.ItemStatusProperty,
e.OldValue,
e.NewValue);
}
}
@@ -39,6 +39,7 @@ namespace Avalonia.Win32.Automation
{ AutomationElementIdentifiers.HelpTextProperty, UiaPropertyId.HelpText },
{ AutomationElementIdentifiers.LandmarkTypeProperty, UiaPropertyId.LandmarkType },
{ AutomationElementIdentifiers.HeadingLevelProperty, UiaPropertyId.HeadingLevel },
{ AutomationElementIdentifiers.ItemStatusProperty, UiaPropertyId.ItemStatus },
{ ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, UiaPropertyId.ExpandCollapseExpandCollapseState },
{ RangeValuePatternIdentifiers.IsReadOnlyProperty, UiaPropertyId.RangeValueIsReadOnly},
{ RangeValuePatternIdentifiers.MaximumProperty, UiaPropertyId.RangeValueMaximum },
@@ -135,6 +136,8 @@ namespace Avalonia.Win32.Automation
UiaPropertyId.IsEnabled => InvokeSync(() => Peer.IsEnabled()),
UiaPropertyId.IsKeyboardFocusable => InvokeSync(() => Peer.IsKeyboardFocusable()),
UiaPropertyId.IsOffscreen => InvokeSync(() => Peer.IsOffscreen()),
UiaPropertyId.ItemType => InvokeSync(() => Peer.GetItemType()),
UiaPropertyId.ItemStatus => InvokeSync(() => Peer.GetItemStatus()),
UiaPropertyId.LocalizedControlType => InvokeSync(() => Peer.GetLocalizedControlType()),
UiaPropertyId.Name => InvokeSync(() => Peer.GetName()),
UiaPropertyId.HelpText => InvokeSync(() => Peer.GetHelpText()),