Thats a great question thanks for posting it in QandA platform
lemme drop you a workaround to prevent the narrator from repeating itself could be to handle the accessibility announcements manually. like below
first disable the default accessibility announcements by setting the AutomationProperties.Name property to an empty string.
and handle the accessibility announcements manually by subscribing to the Toggled event of the ToggleSwitch and using the Narrator API to announce the state change.
let me update the XAML code and add event handlers .
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> <ToggleSwitch Header="A" />
<Grid>
<ToggleSwitch Header="B" OffContent="Disable" OnContent="Enable" AutomationProperties.Name="" Toggled="ToggleSwitch_Toggled" />
</Grid>
</StackPanel>
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) { ToggleSwitch toggleSwitch = sender as ToggleSwitch;
string announcement = toggleSwitch.IsOn ? "Enabled" : "Disabled"; AutomationProperties.SetName(toggleSwitch, announcement); PeerSettings.AnnounceAccessibilityNotification(PeerSettings.AutomationNotificationKind.Other, PeerSettings.AutomationNotificationProcessing.ImportantMostRecent, announcement); }
If this helps kindly accept the answer thanks much/,