Skip to content

[Windows] Implemented the AutomationPeers to the Border control #27713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue27627.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 27627, "[Windows] Border Automation Peer", PlatformAffected.UWP)]
public partial class Issue27627 : ContentPage
{
public Issue27627()
{
var grid = new Grid();

var border = new Border
{
AutomationId = "TestBorder",
VerticalOptions = LayoutOptions.Center,
HeightRequest = 100,
Stroke = Colors.Red
};

var label = new Label
{
Text = "Test Label",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};

border.Content = label;

grid.Children.Add(border);
Content = grid;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue27627 : _IssuesUITest
{
public override string Issue => "[Windows] Border Automation Peer";

public Issue27627(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.Border)]
public void VerifyBorderAutomationPeer()
{
App.WaitForElement("TestBorder");
}
}
}
11 changes: 11 additions & 0 deletions src/Core/src/Platform/Windows/ContentPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Hosting;
using Microsoft.UI.Xaml.Shapes;
using Microsoft.UI.Xaml.Automation.Peers;

namespace Microsoft.Maui.Platform
{
Expand Down Expand Up @@ -65,6 +66,16 @@ internal FrameworkElement? Content
return size;
}

protected override AutomationPeer OnCreateAutomationPeer()
{
if (CrossPlatformLayout is IBorderView)
{
return new MauiBorderAutomationPeer(this);
}

return base.OnCreateAutomationPeer();
}

public ContentPanel()
{
_borderPath = new Path();
Expand Down
24 changes: 24 additions & 0 deletions src/Core/src/Platform/Windows/MauiBorderAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;

namespace Microsoft.Maui.Platform
{
public class MauiBorderAutomationPeer : FrameworkElementAutomationPeer
{
public MauiBorderAutomationPeer(Panel owner) : base(owner) { }

protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Pane;
}

protected override string GetClassNameCore()
{
return nameof(Panel);
}

protected override bool IsControlElementCore() => true;

protected override bool IsContentElementCore() => true;
}
}
7 changes: 7 additions & 0 deletions src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEve
*REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView!
Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView?
Microsoft.Maui.IWindow.TitleBar.get -> Microsoft.Maui.ITitleBar?
Microsoft.Maui.Platform.MauiBorderAutomationPeer
Microsoft.Maui.Platform.MauiBorderAutomationPeer.MauiBorderAutomationPeer(Microsoft.UI.Xaml.Controls.Panel! owner) -> void
Microsoft.Maui.Platform.MauiHybridWebView
Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handlers.HybridWebViewHandler! handler) -> void
Microsoft.Maui.Platform.MauiHybridWebView.RunAfterInitialize(System.Action! action) -> void
Expand All @@ -54,6 +56,11 @@ Microsoft.Maui.WebProcessTerminatedEventArgs.Sender.get -> Microsoft.Web.WebView
override Microsoft.Maui.Handlers.HybridWebViewHandler.ConnectHandler(Microsoft.UI.Xaml.Controls.WebView2! platformView) -> void
override Microsoft.Maui.Handlers.HybridWebViewHandler.CreatePlatformView() -> Microsoft.UI.Xaml.Controls.WebView2!
override Microsoft.Maui.Handlers.HybridWebViewHandler.DisconnectHandler(Microsoft.UI.Xaml.Controls.WebView2! platformView) -> void
override Microsoft.Maui.Platform.ContentPanel.OnCreateAutomationPeer() -> Microsoft.UI.Xaml.Automation.Peers.AutomationPeer!
override Microsoft.Maui.Platform.MauiBorderAutomationPeer.GetAutomationControlTypeCore() -> Microsoft.UI.Xaml.Automation.Peers.AutomationControlType
override Microsoft.Maui.Platform.MauiBorderAutomationPeer.GetClassNameCore() -> string!
override Microsoft.Maui.Platform.MauiBorderAutomationPeer.IsContentElementCore() -> bool
override Microsoft.Maui.Platform.MauiBorderAutomationPeer.IsControlElementCore() -> bool
static Microsoft.Maui.ElementHandlerExtensions.GetRequiredService<T>(this Microsoft.Maui.IElementHandler! handler, System.Type! type) -> T
static Microsoft.Maui.ElementHandlerExtensions.GetRequiredService<T>(this Microsoft.Maui.IElementHandler! handler) -> T
static Microsoft.Maui.ElementHandlerExtensions.GetService<T>(this Microsoft.Maui.IElementHandler! handler, System.Type! type) -> T?
Expand Down
Loading