Skip to content

Automation peers of WinUI controls-library controls return a short ClassName instead of the namespace-qualified one #24992

Closed

Description

@MartinZikmund

Current behavior 🐛

AutomationPeer.GetClassName() returns the bare type name (for example "InfoBar") for the automation peers of 19 controls that come from the WinUI controls library (the former WinUI 2 / MUX controls):

AnimatedVisualPlayer, BreadcrumbBarItem, ColorSpectrum, InfoBar, ItemContainer, ItemsView, MenuBarItem, NavigationViewItem, PagerControl, PersonPicture, PipsPager, ProgressRing, SelectorBarItem, TabView, TabViewItem, TeachingTip, TitleBar, TreeViewItem, WebView2.

Other peers ported from the same library already return the fully-qualified name: Expander, NumberBox, SplitButton, ToggleSplitButton, DropDownButton, RadioButtons, ProgressBar.

Expected behavior 🎯

Like WinUI, these peers should return the namespace-qualified runtime class name, e.g. "Microsoft.UI.Xaml.Controls.InfoBar" (and "Microsoft.UI.Xaml.Controls.Primitives.ColorSpectrum" for ColorSpectrum).

In WinUI every one of these peers implements GetClassNameCore as return winrt::hstring_name_of<winrt::T>();, and hstring_name_of is hstring(winrt::name_of<T>()), the fully-qualified WinRT class name (CppWinRTHelpers.h). Examples:

The same pattern is used in controls/dev/* for all 19 controls listed above.

Note: this only applies to the controls-library peers. Core peers (e.g. ButtonAutomationPeer in dxaml/xcp) return a short name like L"Button" in WinUI too, so they are not affected.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Create a new Uno app (dotnet new unoapp) and run it on any Skia target.
  2. Run this code (e.g. in a button click handler) and look at the output:
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;

var peer = FrameworkElementAutomationPeer.CreatePeerForElement(new InfoBar());
System.Diagnostics.Debug.WriteLine(peer.GetClassName());
// Uno:   InfoBar
// WinUI: Microsoft.UI.Xaml.Controls.InfoBar

var expander = FrameworkElementAutomationPeer.CreatePeerForElement(new Expander());
System.Diagnostics.Debug.WriteLine(expander.GetClassName());
// Uno and WinUI: Microsoft.UI.Xaml.Controls.Expander

A runtime test that checks all 19 controls (plus Expander and NumberBox as controls) fails on Skia Desktop on current master with 19 mismatches:

FAIL AnimatedVisualPlayerAutomationPeer: GetClassName()="AnimatedVisualPlayer" expected "Microsoft.UI.Xaml.Controls.AnimatedVisualPlayer"
FAIL BreadcrumbBarItemAutomationPeer: GetClassName()="BreadcrumbBarItem" expected "Microsoft.UI.Xaml.Controls.BreadcrumbBarItem"
FAIL ColorSpectrumAutomationPeer: GetClassName()="ColorSpectrum" expected "Microsoft.UI.Xaml.Controls.Primitives.ColorSpectrum"
FAIL InfoBarAutomationPeer: GetClassName()="InfoBar" expected "Microsoft.UI.Xaml.Controls.InfoBar"
FAIL ItemContainerAutomationPeer: GetClassName()="ItemContainer" expected "Microsoft.UI.Xaml.Controls.ItemContainer"
FAIL ItemsViewAutomationPeer: GetClassName()="ItemsView" expected "Microsoft.UI.Xaml.Controls.ItemsView"
FAIL MenuBarItemAutomationPeer: GetClassName()="MenuBarItem" expected "Microsoft.UI.Xaml.Controls.MenuBarItem"
FAIL NavigationViewItemAutomationPeer: GetClassName()="NavigationViewItem" expected "Microsoft.UI.Xaml.Controls.NavigationViewItem"
FAIL PagerControlAutomationPeer: GetClassName()="PagerControl" expected "Microsoft.UI.Xaml.Controls.PagerControl"
FAIL PersonPictureAutomationPeer: GetClassName()="PersonPicture" expected "Microsoft.UI.Xaml.Controls.PersonPicture"
FAIL PipsPagerAutomationPeer: GetClassName()="PipsPager" expected "Microsoft.UI.Xaml.Controls.PipsPager"
FAIL ProgressRingAutomationPeer: GetClassName()="ProgressRing" expected "Microsoft.UI.Xaml.Controls.ProgressRing"
FAIL SelectorBarItemAutomationPeer: GetClassName()="SelectorBarItem" expected "Microsoft.UI.Xaml.Controls.SelectorBarItem"
FAIL TabViewAutomationPeer: GetClassName()="TabView" expected "Microsoft.UI.Xaml.Controls.TabView"
FAIL TabViewItemAutomationPeer: GetClassName()="TabViewItem" expected "Microsoft.UI.Xaml.Controls.TabViewItem"
FAIL TeachingTipAutomationPeer: GetClassName()="TeachingTip" expected "Microsoft.UI.Xaml.Controls.TeachingTip"
FAIL TitleBarAutomationPeer: GetClassName()="TitleBar" expected "Microsoft.UI.Xaml.Controls.TitleBar"
FAIL TreeViewItemAutomationPeer: GetClassName()="TreeViewItem" expected "Microsoft.UI.Xaml.Controls.TreeViewItem"
FAIL WebView2AutomationPeer: GetClassName()="WebView2" expected "Microsoft.UI.Xaml.Controls.WebView2"
OK   ExpanderAutomationPeer: GetClassName()="Microsoft.UI.Xaml.Controls.Expander" expected "Microsoft.UI.Xaml.Controls.Expander"
OK   NumberBoxAutomationPeer: GetClassName()="Microsoft.UI.Xaml.Controls.NumberBox" expected "Microsoft.UI.Xaml.Controls.NumberBox"

Workaround 🛠️

Subclass the control, override OnCreateAutomationPeer, and return a derived peer whose GetClassNameCore() returns typeof(TControl).FullName.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

All platforms 🌍 (except Windows App SDK)

Uno.Sdk version (and other relevant versions) 📦

Current master (bfc8dff), runtime test run on Skia Desktop (Windows).

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

Evidence: the WinUI behavior is backed by the WinUI C++ sources linked above (no native WinUI run). The Uno behavior is backed by a runtime test on Skia Desktop.

Root cause: when these peers were ported, winrt::hstring_name_of<winrt::T>() was translated to nameof(T) (short name) instead of typeof(T).FullName (as done for Expander, NumberBox, SplitButton, etc.). For example:

Suggested fix: in each affected GetClassNameCore, replace nameof(T) with typeof(T).FullName!. Files on master:

  • src/Uno.UI/UI/Xaml/Automation/Peers/AnimatedVisualPlayerAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Automation/Peers/WebView2AutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/BreadcrumbBar/BreadcrumbBarItemAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/ColorPicker/ColorSpectrumAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/InfoBar/InfoBarAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/ItemContainer/ItemContainerAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/ItemsView/ItemsViewAutomationPeer.cs (a fix for this one is in progress)
  • src/Uno.UI/UI/Xaml/Controls/MenuBar/MenuBarItemAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/NavigationView/NavigationViewItemAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/PagerControl/PagerControlAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/PersonPicture/PersonPictureAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/PipsPager/PipsPagerAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/ProgressRing/ProgressRingAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/SelectorBar/SelectorBarItemAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/TabView/TabViewAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/TabView/TabViewItemAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/TeachingTip/TeachingTipAutomationPeer.cs
  • src/Uno.UI/UI/Xaml/Controls/TitleBar/TitleBarAutomationPeer.mux.cs
  • src/Uno.UI/UI/Xaml/Controls/TreeView/TreeViewItemAutomationPeer.cs

A runtime test can create each control, call FrameworkElementAutomationPeer.CreatePeerForElement(control).GetClassName(), and compare it with control.GetType().FullName.

Impact: UI automation scripts and accessibility tools that key on the UIA ClassName property see different values on Uno than on WinUI for these controls.

Activity

  1. added
    kind/bug
    good first issue
    platform/wasm 🌐
    platform/android 🤖
    platform/ios 🍎
    triage/untriaged
    area/a11y
    difficulty/starter 🚀
    area/porting 🖨️
    platform/desktop 🖥️
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/a11yarea/porting 🖨️difficulty/starter 🚀good first issuekind/bugplatform/android 🤖platform/desktop 🖥️platform/ios 🍎platform/wasm 🌐triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions