From 79239b5842c1aecafded476b90d980d43b2e2cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C4=8Dera?= <10546952+miloush@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:59:20 +0000 Subject: [PATCH] ItemStatus and ItemType UIA properties (#20669) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ItemStatus and ItemType UIA properties * ItemStatus property change notification --------- Co-authored-by: Jan Kučera --- .../AutomationElementIdentifiers.cs | 6 +++ .../Automation/Peers/AutomationPeer.cs | 37 +++++++++++++++++++ .../Automation/Peers/ControlAutomationPeer.cs | 9 +++++ .../AutomationNode.cs | 3 ++ 4 files changed, 55 insertions(+) diff --git a/src/Avalonia.Controls/Automation/AutomationElementIdentifiers.cs b/src/Avalonia.Controls/Automation/AutomationElementIdentifiers.cs index 8cdee8e3fe..9e28080cb5 100644 --- a/src/Avalonia.Controls/Automation/AutomationElementIdentifiers.cs +++ b/src/Avalonia.Controls/Automation/AutomationElementIdentifiers.cs @@ -31,6 +31,12 @@ namespace Avalonia.Automation /// public static AutomationProperty HelpTextProperty { get; } = new AutomationProperty(); + /// + /// Identifies the itemStatus automation property. The class name property value is returned + /// by the method. + /// + public static AutomationProperty ItemStatusProperty { get; } = new AutomationProperty(); + /// /// Identifies the landmark type automation property. The class name property value is returned /// by the method. diff --git a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs index 56111bdc83..b32b60118c 100644 --- a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs @@ -319,6 +319,41 @@ namespace Avalonia.Automation.Peers /// public int GetHeadingLevel() => GetHeadingLevelCore(); + + /// + /// Gets the item type that is associated with this automation peer. + /// + /// + /// + /// + /// Windows + /// UIA_ItemTypePropertyId + /// + /// + /// macOS + /// No mapping. + /// + /// + /// + public string? GetItemType() => GetItemTypeCore(); + + /// + /// Gets the item status that is associated with this automation peer. + /// + /// + /// + /// + /// Windows + /// UIA_ItemStatusPropertyId + /// + /// + /// macOS + /// No mapping. + /// + /// + /// + public string? GetItemStatus() => GetItemStatusCore(); + /// /// Gets the that is the parent of this . /// @@ -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(); diff --git a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs index c59ba6b148..cdab4911f2 100644 --- a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs @@ -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); + } } diff --git a/src/Windows/Avalonia.Win32.Automation/AutomationNode.cs b/src/Windows/Avalonia.Win32.Automation/AutomationNode.cs index 8562807452..78f562decf 100644 --- a/src/Windows/Avalonia.Win32.Automation/AutomationNode.cs +++ b/src/Windows/Avalonia.Win32.Automation/AutomationNode.cs @@ -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()),