-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[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
base: main
Are you sure you want to change the base?
[Windows] Implemented the AutomationPeers to the Border control #27713
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Files not reviewed (1)
- src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt: Language not supported
Comments suppressed due to low confidence (2)
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27627.cs:7
- [nitpick] The class name Issue27627 is not descriptive. Consider renaming it to BorderAutomationPeerTests.
public class Issue27627 : _IssuesUITest
src/Controls/tests/TestCases.HostApp/Issues/Issue27627.cs:19
- The test case does not verify the functionality of the MauiBorderAutomationPeer. It only waits for the element with the AutomationId 'TestBorder'. Add a more comprehensive test to verify the functionality of the automation peer.
App.WaitForElement("TestBorder");
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the typical "we can;t do cool new things in .NET 9".
But, I am super out pf the a11y loop here, so can you just update the PR description with info on what your reasonoing is with the 4 methods in the peer? The Get*Core methods. I see the other 2 peers we have in maui do not have these.
Also, just for confirmation, can you still select elements inside the border via the various a11y nav options - like keyboard and such?
|
|
||
| namespace Microsoft.Maui.Platform | ||
| { | ||
| public class MauiBorderAutomationPeer : FrameworkElementAutomationPeer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be internal for .NET 9, and public in .NET 10.
Can you make this internal for now, and then open an issue so we can make it public for .NET 10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you suggested, I changed it to internal, created a new issue #30205 to track this change, and included it for reference.
| [Category(UITestCategories.Border)] | ||
| public void VerifyBorderAutomationPeer() | ||
| { | ||
| App.WaitForElement("TestBorder"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before you set the automation peer, is this not possible? I mean, this test appears to be looking for a element with this ID, so I just want to check if the test would fail without this new peer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattleibow, I have updated the PR description with the relevant details. Regarding accessibility navigation, yes, it still allows navigating to the child elements within the Border. For example, if an Entry is placed inside the Border, pressing the Tab key will move focus to the Entry as expected. |
6402596 to
fd4179b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The automation peer needs to only activate when a gesture is attached to it.
Similar to how android and ios work where we change the accessibility features.
fd4179b to
ef45d50
Compare
da60565 to
d61c0e9
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
|
||
| protected override bool IsKeyboardFocusableCore() => true; | ||
|
|
||
| protected override bool IsControlElementCore() => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a comment would be nice here:
- Control View: Contains user-interactive borders (with gesture recognizers)
- Content View: Allows screen readers to announce border structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the comments
| { | ||
| var grid = new Grid(); | ||
|
|
||
| var border = new Border |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could expand the sample to test more scenarios?
- Nested Borders. Each gets own automation peer via
OnCreateAutomationPeer() - Border with custom Content.
IsContentElementCore = trueensures nested content exposed to screen readers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, I have modified the test sample as suggested.
@PureWeen, I have modified the implementation as suggested and updated the details in the PR description. |


Description of Change
Implemented AutomationPeer support for the Windows Border control.
Added keyboard accessibility by invoking the TapGestureRecognizer when the Enter or Space key is pressed, if a TapGestureRecognizer is attached to the Border.
The Border can now receive focus (IsTabStop = true) only when a TapGestureRecognizer is added, ensuring it behaves like an interactive element.
Accessibility support is implemented using a custom MauiBorderAutomationPeer, derived from FrameworkElementAutomationPeer.
This peer is introduced to support accessibility for the custom MauiBorder implementation, which is built using a Panel. Since Panel does not provide a default AutomationPeer, we explicitly define one (MauiBorderAutomationPeer).
Screenshots
Note: In the following video:
The first Border (containing the CheckBox) does not have a TapGestureRecognizer, so it does not receive focus during keyboard navigation.
The second Border (containing the Label) initially has a TapGestureRecognizer attached. It receives focus as expected, and the Tapped event is correctly fired when pressing the Space or Enter key.
The TapGestureRecognizer is then removed at runtime using the “Remove TapGestureRecognizer” button and added again using the “Add TapGestureRecognizer” button.
After removing it at runtime, the second Border no longer receives focus. Once it is added back, the focus behavior and keyboard interaction work as expected again.
Screen.Recording.mp4
Overridden Core Methods and their Purpose
1. GetAutomationControlTypeCore()
2. GetClassNameCore()
Panelto reflect the underlying native element.3. IsControlElementCore()
4. IsContentElementCore()
Issues Fixed
Fixes #27627