diff --git a/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs new file mode 100644 index 0000000000..4ea950df7e --- /dev/null +++ b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs @@ -0,0 +1,27 @@ +using Avalonia.Automation.Peers; +using Avalonia.Controls.Primitives; + +namespace Avalonia.Controls.Automation.Peers +{ + public class LabelAutomationPeer : ControlAutomationPeer + { + public LabelAutomationPeer(Label owner) : base(owner) + { + } + + override protected string GetClassNameCore() + { + return "Text"; + } + + override protected AutomationControlType GetAutomationControlTypeCore() + { + return AutomationControlType.Text; + } + + override protected string GetNameCore() + { + return AccessText.RemoveAccessKeyMarker(((Label)Owner).Content as string) ?? string.Empty; + } + } +} diff --git a/src/Avalonia.Controls/Label.cs b/src/Avalonia.Controls/Label.cs index 5c8a6e0a5b..cabbb5adf7 100644 --- a/src/Avalonia.Controls/Label.cs +++ b/src/Avalonia.Controls/Label.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; +using Avalonia.Automation.Peers; +using Avalonia.Controls.Automation.Peers; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.Data; @@ -71,5 +73,10 @@ namespace Avalonia.Controls } base.OnPointerPressed(e); } + + protected override AutomationPeer OnCreateAutomationPeer() + { + return new LabelAutomationPeer(this); + } } }