Browse Source

Add LabelAutomationPeer

pull/10531/head
Daniil Pavliuchyk 3 years ago
parent
commit
de50cda755
  1. 27
      src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs
  2. 7
      src/Avalonia.Controls/Label.cs

27
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;
}
}
}

7
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);
}
}
}

Loading…
Cancel
Save