Narrator repeats one extra time at ToggleSwitch when OnContent or OffContent is set in UWP #9326
Labels
appModel-UWP
Exclusive to WinUI 2 UWP apps
area-ToggleSwitch
bug
Something isn't working
team-Controls
Issue for the Controls team
Describe the bug
I am currently implementing a custom
ToggleSwitch
in UWP based on Microsoft's template. However, I've encountered a peculiar bug related to the narrator behavior, which seems to be resolved in WinUI 3 but persists in UWP (WinUI 2). I'm seeking assistance to address this issue.If the
OnContent
orOffContent
is set at the toggle switch it will cause the narrator to repeat itself one time. If you don't use this properties, it reads perfectly, without repeating itself.In the provided example code, the first
ToggleSwitch
with thex:Name
'A' behaves correctly. However, when theOnContent
andOffContent
properties are set, as in the secondToggleSwitch
with thex:Name
'B,' the narrator repeats itself one extra time. The expected behavior is to read 'Enable, Toggle Switch, ON' or 'Disable, Toggle Switch, OFF,' but it reads something like 'Enable, Toggle Switch, ON, Enable, Toggle Switch, ON." or the analogueHow can I overcome this issue and prevent the narrator from repeating itself when using the
OnContent
andOffContent
properties in a UWP ToggleSwitch? Any insights or workarounds would be greatly appreciated.Steps to reproduce the bug
[BUG] - Narrator read twice: On/Off Content+ component+ state
Expected behavior
Narrator read once: On/Off Content+ component+ state
Screenshots
Toggle Switch Narrator Test.zip
NuGet package version
WinUI 2 - Microsoft.UI.Xaml 2.8.2
Windows version
Windows 10: Build 19041 (version 2004)
Additional context
I've already posted something similar at: https://learn.microsoft.com/en-us/answers/questions/1526247/how-to-make-narrator-do-not-repeat-the-sentence-wh
I still had no success to work this around.
I've attempted to use
AutomationProperties.SetName(component, name)
but it does not work in every scenario for me.Also, tried to implement a
AutomationPeer
but theToggleSwitch
is a sealed class. Therefore, I'm using composition. As a result, I couldn't useToggleSwitchAutomationPeer
even when passing the component as a parameter. I attempted to useFrameworkElementAutomationPeer
instead and I've implemented it similarly toToggleSwitchAutomationPeer
(like described on the section remarks on this link ToggleSwitchAutomationPeer) but it always seems to result in a wrong case, not always on the narrator, but sometimes it don't focus right with the proper narrator border, because the control itself do not inherits from toggle switch, it contains one toggle switch, that messes everything up.The text was updated successfully, but these errors were encountered: