From c95d61c7a4513bf8e60d7877a299043d69bdaed1 Mon Sep 17 00:00:00 2001 From: "Maria Manolova (INFRAGISTICS INC)" Date: Mon, 13 Jul 2026 17:49:55 +0300 Subject: [PATCH] Fix accessible Name including control type on ControlExample source expander 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 #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> --- .../WPFGallery/Controls/ControlExample.xaml | 3 +- .../RemoveControlTypeFromNameConverter.cs | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Sample Applications/WPFGallery/Helpers/RemoveControlTypeFromNameConverter.cs diff --git a/Sample Applications/WPFGallery/Controls/ControlExample.xaml b/Sample Applications/WPFGallery/Controls/ControlExample.xaml index d476e7ab8..e573125b0 100644 --- a/Sample Applications/WPFGallery/Controls/ControlExample.xaml +++ b/Sample Applications/WPFGallery/Controls/ControlExample.xaml @@ -12,6 +12,7 @@ xmlns:helpers="clr-namespace:WPFGallery.Helpers"> +