Skip to content

Fix accessible Name including control type on ControlExample source expander#798

Open
mmanolova-msft wants to merge 1 commit into
microsoft:mainfrom
mmanolova-msft:fix/3018244-controlexample-source-expander-name
Open

Fix accessible Name including control type on ControlExample source expander#798
mmanolova-msft wants to merge 1 commit into
microsoft:mainfrom
mmanolova-msft:fix/3018244-controlexample-source-expander-name

Conversation

@mmanolova-msft

@mmanolova-msft mmanolova-msft commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The three linked work items report that on some WPF Gallery pages a button's accessible Name includes its own localized control type (MAS 4.1.2 / axe-windows NameExcludesLocalizedControlType).

The failures do not come from the demo controls themselves, but from the shared ControlExample "View Source Code" Expander. Its Name is set to View Source Code for {HeaderText}, and the Fluent Expander template forwards that Name onto the header ToggleButton (control type button). So any example whose header contains the whole word "Button" — e.g. Simple Button, WPF Accent Button — yields a button named "…Button", which includes its own control type.

The unique per-example name was introduced in #598; this PR keeps that uniqueness while removing the control-type collision.

Fix

  • Add RemoveControlTypeFromNameConverter — strips the whole-word control type (case-insensitive, matching the axe-windows rule) supplied via ConverterParameter. If stripping would empty the string, the original value is kept so the Name is never blank.
  • Apply it to the ControlExample Expander's AutomationProperties.Name binding with ConverterParameter=Button.

Effect

Only headers containing the whole word "Button" change:

Header Before After
Simple Button View Source Code for Simple Button View Source Code for Simple
WPF Accent Button View Source Code for WPF Accent Button View Source Code for WPF Accent

All other pages (including headerless examples) are unchanged. The demo buttons themselves were already compliant.

Fixes AB#3018244, AB#3018295

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Microsoft Reviewers: Open in CodeFlow

…xpander

The shared ControlExample "View Source Code" Expander sets
AutomationProperties.Name to "View Source Code for {HeaderText}". The Fluent
Expander template forwards that Name onto the header ToggleButton (control
type "button"), so any header containing the whole word "Button" (e.g.
"Simple Button", "WPF Accent Button") produces a button whose accessible name
includes its own localized control type. This violates MAS 4.1.2 / the
axe-windows NameExcludesLocalizedControlType rule.

Introduce RemoveControlTypeFromNameConverter, which strips the whole-word
control type (case-insensitive) from the header before it is formatted into
the Name, preserving the unique per-example name added in microsoft#598 while removing
the control-type collision. If stripping would empty the string, the original
value is kept so the Name is never blank.

Fixes AB#3018244, AB#3018295

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant