diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/Setting/Setting.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/Setting/Setting.cs index acca823774..c2a9a7d69d 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/Setting/Setting.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/Setting/Setting.cs @@ -3,7 +3,9 @@ // See the LICENSE file in the project root for more information. using System.ComponentModel; +using Windows.UI.Accessibility; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation; using Windows.UI.Xaml.Controls; namespace Microsoft.PowerToys.Settings.UI.Controls @@ -29,7 +31,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls "Header", typeof(string), typeof(Setting), - new PropertyMetadata(default(string))); + new PropertyMetadata(default(string), OnHeaderChanged)); public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register( "Description", @@ -87,6 +89,11 @@ namespace Microsoft.PowerToys.Settings.UI.Controls base.OnApplyTemplate(); } + private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((Setting)d).Update(); + } + private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((Setting)d).Update(); @@ -114,6 +121,14 @@ namespace Microsoft.PowerToys.Settings.UI.Controls return; } + if (_setting.ActionContent != null) + { + if (!string.IsNullOrEmpty(_setting.Header)) + { + AutomationProperties.SetName((UIElement)_setting.ActionContent, _setting.Header); + } + } + if (_setting._iconPresenter != null) { if (_setting.Icon == null) diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/SettingExpander/SettingExpander.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/SettingExpander/SettingExpander.cs new file mode 100644 index 0000000000..4d8aabcbd9 --- /dev/null +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Controls/SettingExpander/SettingExpander.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation +// 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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.UI.Xaml.Controls; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation; + +namespace Microsoft.PowerToys.Settings.UI.Controls +{ + public partial class SettingExpander : Expander + { + public SettingExpander() + { + DefaultStyleKey = typeof(Expander); + this.Style = (Style)App.Current.Resources["SettingExpanderStyle"]; + this.RegisterPropertyChangedCallback(Expander.HeaderProperty, OnHeaderChanged); + } + + private static void OnHeaderChanged(DependencyObject d, DependencyProperty dp) + { + SettingExpander self = (SettingExpander)d; + if (self.Header != null) + { + if (self.Header.GetType() == typeof(Setting)) + { + Setting selfSetting = (Setting)self.Header; + selfSetting.Style = (Style)App.Current.Resources["ExpanderHeaderSettingStyle"]; + + if (!string.IsNullOrEmpty(selfSetting.Header)) + { + AutomationProperties.SetName(self, selfSetting.Header); + } + } + } + } + } +} diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index bd4c70e2ef..8360224979 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -99,6 +99,7 @@ HotkeySettingsControl.xaml + diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml index 85d4b558fd..a8ee04e2b1 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Themes/SettingsExpanderStyles.xaml @@ -32,7 +32,8 @@ -