-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix WPF Gallery Narrator accessibility issues (Colors, Icons, User Dashboard) #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dipeshmsft
merged 5 commits into
microsoft:main
from
wnvko-msft:mvenkov/fix-wpfgallery-a11y
Jul 6, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
17e70ff
Fix Narrator silence on Colors page selector ComboBox (WCAG 4.1.2)
wnvko-msft 020c626
Fix Narrator scan mode skipping icon data values on Icons page (MAS 1…
wnvko-msft 72f9191
Announce actual age value on Age slider in User Dashboard (MAS 1.3.1)
wnvko-msft d2ee21a
Fix duplicate Narrator announcements on Icons page
wnvko-msft 4d73b03
Merge remote-tracking branch 'upstream/main' into mvenkov/fix-wpfgall…
wnvko-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
Sample Applications/WPFGallery/Controls/IconDataField.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <UserControl x:Class="WPFGallery.Controls.IconDataField" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| mc:Ignorable="d" | ||
| x:Name="Root" | ||
| Focusable="False" | ||
| Margin="0,0,0,12"> | ||
|
|
||
| <Grid> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="*" /> | ||
| <ColumnDefinition Width="Auto" /> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <!-- The value is shown by a TextBlock placed directly in the control's | ||
| content (not inside a ControlTemplate), so it is exposed to UI | ||
| Automation as real content and reachable by Narrator scan mode. --> | ||
| <TextBlock Grid.Column="0" | ||
| VerticalAlignment="Center" | ||
| MinHeight="32" | ||
| Padding="0,6" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{DynamicResource TextFillColorPrimaryBrush}" | ||
| Text="{Binding Value, ElementName=Root}" | ||
| TextWrapping="Wrap" /> | ||
|
|
||
| <Button Grid.Column="1" | ||
| Padding="8" | ||
| FocusManager.IsFocusScope="True" | ||
| Click="CopyButton_Click" | ||
| AutomationProperties.Name="{Binding Label, ElementName=Root, StringFormat='{}Copy {0} to clipboard'}" | ||
| ToolTipService.ToolTip="Copy to clipboard"> | ||
| <Grid> | ||
| <TextBlock x:Name="CopyGlyphTextBlock" FontFamily="{StaticResource SymbolThemeFontFamily}" Text="" /> | ||
| <TextBlock x:Name="SuccessGlyphTextBlock" FontFamily="{StaticResource SymbolThemeFontFamily}" Text="" Opacity="0" /> | ||
| </Grid> | ||
| <Button.Triggers> | ||
| <EventTrigger RoutedEvent="Button.Click"> | ||
| <EventTrigger.Actions> | ||
| <BeginStoryboard> | ||
| <Storyboard BeginTime="00:00:00"> | ||
| <DoubleAnimation Duration="0:0:0.333" Storyboard.TargetName="CopyGlyphTextBlock" Storyboard.TargetProperty="Opacity" To="0" /> | ||
| <DoubleAnimation Duration="0:0:0.666" BeginTime="0:0:0.333" Storyboard.TargetName="SuccessGlyphTextBlock" Storyboard.TargetProperty="Opacity" To="1" /> | ||
| <DoubleAnimation Storyboard.TargetName="SuccessGlyphTextBlock" BeginTime="0:0:2" Duration="0:0:0.01" Storyboard.TargetProperty="Opacity" To="0" /> | ||
| <DoubleAnimation Storyboard.TargetName="CopyGlyphTextBlock" BeginTime="0:0:2.1" Duration="0:0:0.01" Storyboard.TargetProperty="Opacity" To="1" /> | ||
| </Storyboard> | ||
| </BeginStoryboard> | ||
| </EventTrigger.Actions> | ||
| </EventTrigger> | ||
| </Button.Triggers> | ||
| </Button> | ||
| </Grid> | ||
| </UserControl> | ||
63 changes: 63 additions & 0 deletions
63
Sample Applications/WPFGallery/Controls/IconDataField.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| using System.Windows.Automation; | ||
| using System.Windows.Automation.Peers; | ||
|
|
||
| namespace WPFGallery.Controls | ||
| { | ||
| /// <summary> | ||
| /// Interaction logic for IconDataField.xaml. | ||
| /// Displays a single read-only icon metadata value (e.g. icon name, Unicode | ||
| /// code point or glyph) together with a button that copies the value to the | ||
| /// clipboard. The value is rendered by a TextBlock that lives in the | ||
| /// control's content tree, so it is exposed to UI Automation as content and | ||
| /// is reachable by Narrator scan mode. | ||
| /// </summary> | ||
| public partial class IconDataField : UserControl | ||
| { | ||
| public IconDataField() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| public string Value | ||
| { | ||
| get { return (string)GetValue(ValueProperty); } | ||
| set { SetValue(ValueProperty, value); } | ||
| } | ||
|
|
||
| public static readonly DependencyProperty ValueProperty = | ||
| DependencyProperty.Register(nameof(Value), typeof(string), typeof(IconDataField), new PropertyMetadata(string.Empty)); | ||
|
|
||
| public string Label | ||
| { | ||
| get { return (string)GetValue(LabelProperty); } | ||
| set { SetValue(LabelProperty, value); } | ||
| } | ||
|
|
||
| public static readonly DependencyProperty LabelProperty = | ||
| DependencyProperty.Register(nameof(Label), typeof(string), typeof(IconDataField), new PropertyMetadata(string.Empty)); | ||
|
|
||
| private void CopyButton_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| if (string.IsNullOrEmpty(Value)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| Clipboard.SetText(Value); | ||
| AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this); | ||
| peer?.RaiseNotificationEvent( | ||
| AutomationNotificationKind.Other, | ||
| AutomationNotificationProcessing.ImportantMostRecent, | ||
| $"{Label} Copied", | ||
| "ButtonClickedActivity" | ||
| ); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| MessageBox.Show("Error copying to clipboard: " + ex.Message); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.