diff --git a/src/modules/colorPicker/ColorPickerUI/ViewModels/MainViewModel.cs b/src/modules/colorPicker/ColorPickerUI/ViewModels/MainViewModel.cs index 7bc46756ca..baf35baa17 100644 --- a/src/modules/colorPicker/ColorPickerUI/ViewModels/MainViewModel.cs +++ b/src/modules/colorPicker/ColorPickerUI/ViewModels/MainViewModel.cs @@ -118,10 +118,7 @@ namespace ColorPicker.ViewModels { ColorBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B)); ColorText = ColorRepresentationHelper.GetStringRepresentation(color, _userSettings.CopiedColorRepresentation.Value); - if (_userSettings.ShowColorName.Value) - { - ColorName = ColorNameHelper.GetColorName(color); - } + ColorName = ColorNameHelper.GetColorName(color); } /// diff --git a/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml b/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml index a310c4d698..c4dda22413 100644 --- a/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml +++ b/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml @@ -35,14 +35,18 @@ VerticalAlignment="Stretch" BorderBrush="{DynamicResource WindowBorderBrush}" BorderThickness="1" - x:Name="ColorBorderSmall" CornerRadius="4"/> - diff --git a/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml.cs b/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml.cs index 4086aacfcd..89b8224007 100644 --- a/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/Views/MainView.xaml.cs @@ -2,6 +2,9 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.ComponentModel; +using System.Windows; +using System.Windows.Automation.Peers; using System.Windows.Controls; namespace ColorPicker.Views @@ -11,7 +14,41 @@ namespace ColorPicker.Views /// public partial class MainView : UserControl { + private void EnableNarratorColorChangesAnnouncements() + { + INotifyPropertyChanged viewModel = (INotifyPropertyChanged)this.DataContext; + viewModel.PropertyChanged += (sender, args) => + { + if (args.PropertyName != "ColorName") + { + return; + } + + var colorTextBlock = (TextBlock)FindName("ColorTextBlock"); + if (colorTextBlock == null) + { + return; + } + + var peer = UIElementAutomationPeer.FromElement(colorTextBlock); + if (peer == null) + { + peer = UIElementAutomationPeer.CreatePeerForElement(colorTextBlock); + } + + peer.RaiseAutomationEvent(AutomationEvents.MenuOpened); + }; + } + + private void OnLoaded(object sender, RoutedEventArgs e) + { + EnableNarratorColorChangesAnnouncements(); + } + public MainView() - => InitializeComponent(); + { + InitializeComponent(); + Loaded += OnLoaded; + } } }