Skip to content

Commit b35fd5a

Browse files
authored
add automation peer for UserControl (#17480)
* add automation peer for UserControl * fix automation name * change base class to ControlAutomationPeer
1 parent 601425d commit b35fd5a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Avalonia.Automation;
2+
using Avalonia.Automation.Peers;
3+
4+
namespace Avalonia.Controls.Automation.Peers;
5+
6+
public class UserControlAutomationPeer : ControlAutomationPeer
7+
{
8+
public UserControlAutomationPeer(UserControl owner)
9+
: base(owner)
10+
{
11+
}
12+
13+
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Custom;
14+
}

src/Avalonia.Controls/UserControl.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Avalonia.Automation.Peers;
2+
using Avalonia.Controls.Automation.Peers;
13
using Avalonia.Styling;
24

35
namespace Avalonia.Controls
@@ -7,6 +9,6 @@ namespace Avalonia.Controls
79
/// </summary>
810
public class UserControl : ContentControl
911
{
10-
12+
protected override AutomationPeer OnCreateAutomationPeer() => new UserControlAutomationPeer(this);
1113
}
1214
}

0 commit comments

Comments
 (0)