Fix: UIA tree not visible for Avalonia content embedded via WinFormsAvaloniaControlHost#21422
Merged
MrJul merged 2 commits intoMay 26, 2026
Conversation
…onPeer Without IRootProvider, AutomationNode.Create falls back to the plain AutomationNode which doesn't implement IRawElementProviderFragmentRoot and returns null from GetHostRawElementProvider. As a result, UiaReturnRawElementProvider responds with E_FAIL for the WM_GETOBJECT sent to the embedded HWND, and the Avalonia automation tree is invisible to UIA clients (Inspect.exe, Narrator, FlaUI etc.) when the control is hosted via WinFormsAvaloniaControlHost.
|
You can test this PR using the following package version. |
Collaborator
|
Contributor
Author
|
@cla-avalonia agree |
MrJul
approved these changes
May 26, 2026
MrJul
left a comment
Member
There was a problem hiding this comment.
IRootProvider makes sense on EmbeddableControlRoot despite the name: that is a "true" root, i.e. it's backed by a ITopLevelImpl.
LGTM!
MrJul
pushed a commit
to MrJul/Avalonia
that referenced
this pull request
May 28, 2026
…valoniaControlHost (AvaloniaUI#21422) * [Automation] Add EmbeddableControlRootAutomationPeer tests * [Automation] Implement IRootProvider on EmbeddableControlRootAutomationPeer Without IRootProvider, AutomationNode.Create falls back to the plain AutomationNode which doesn't implement IRawElementProviderFragmentRoot and returns null from GetHostRawElementProvider. As a result, UiaReturnRawElementProvider responds with E_FAIL for the WM_GETOBJECT sent to the embedded HWND, and the Avalonia automation tree is invisible to UIA clients (Inspect.exe, Narrator, FlaUI etc.) when the control is hosted via WinFormsAvaloniaControlHost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
Fixes the UIA accessibility tree being invisible for Avalonia content hosted in WinForms/WPF via
WinFormsAvaloniaControlHost. Tools like Inspect.exe, Accessibility Insights for Windows, Narrator and FlaUI see the embedded Avalonia HWND as an opaque[pane]with no children.What is the current behavior?
EmbeddableControlRootAutomationPeerimplementsIEmbeddedRootProviderbut notIRootProvider. In the Win32 backend,AutomationNode.Createonly checks forIRootProviderto instantiateRootAutomationNode:Embedded roots fall into the last branch and get a plain
AutomationNodethat doesn't implementIRawElementProviderFragmentRootand returns null fromGetHostRawElementProvider(noUiaHostProviderFromHwndcall).UiaReturnRawElementProviderthen responds toWM_GETOBJECTwithE_FAIL(0x80004005) and the Avalonia subtree is missing from UIA.What is the updated/expected behavior with this PR?
EmbeddableControlRootAutomationPeeralso implementsIRootProvider.AutomationNode.Createpicks theRootAutomationNodepath,UiaReturnRawElementProvidersucceeds, and the embedded Avalonia tree is fully exposed to UIA clients.Verified by hosting an Avalonia control in a WPF window through
WindowsFormsHost->WinFormsAvaloniaControlHostand inspecting it with Inspect.exe and Accessibility Insights for Windows: the full control tree is now reachable instead of a single[pane].How was the solution implemented (if it's not obvious)?
IRootProviderandIEmbeddedRootProvidershareGetFocus,GetPeerFromPointandFocusChangedwith identical signatures, so the existing implementation satisfies both. The only extraIRootProvidermember,PlatformImpl, is added as an explicit interface implementation forwarding toOwner.PlatformImpl.Checklist