Skip to content

Commit 02ceaad

Browse files
committed
Feedback
1 parent 146174a commit 02ceaad

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

labs/SettingsControls/src/SettingsCard/SettingsCard.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,13 @@ protected override void OnApplyTemplate()
4949

5050
private void RegisterAutomation()
5151
{
52-
if (Header != null && Header.GetType() == typeof(string))
52+
if (Header is string headerString && headerString != string.Empty)
5353
{
54-
string? headerString = Header.ToString();
55-
if (!string.IsNullOrEmpty(headerString))
54+
AutomationProperties.SetName(this, headerString);
55+
// We don't want to override an AutomationProperties.Name that is manually set, or if the Content basetype is of type ButtonBase (the ButtonBase.Content will be used then)
56+
if (Content is UIElement element && string.IsNullOrEmpty(AutomationProperties.GetName(element)) && element.GetType().BaseType != typeof(ButtonBase))
5657
{
57-
AutomationProperties.SetName(this, headerString);
58-
59-
// We don't want to override an AutomationProperties.Name that is manually set, or if the Content basetype is of type ButtonBase (the ButtonBase.Content will be used then)
60-
if (Content != null && string.IsNullOrEmpty(AutomationProperties.GetName((UIElement)Content)) && Content.GetType().BaseType != typeof(ButtonBase))
61-
{
62-
AutomationProperties.SetName((UIElement)Content, headerString);
63-
}
58+
AutomationProperties.SetName(element, headerString);
6459
}
6560
}
6661
}

labs/SettingsControls/src/SettingsExpander/SettingsExpander.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ protected override void OnApplyTemplate()
2727

2828
private void RegisterAutomation()
2929
{
30-
if (Header != null && Header.GetType() == typeof(string))
30+
if (Header is string headerString && headerString != string.Empty)
3131
{
32-
string? headerString = Header.ToString();
3332
if (!string.IsNullOrEmpty(headerString) && string.IsNullOrEmpty(AutomationProperties.GetName(this)))
3433
{
3534
AutomationProperties.SetName(this, headerString);

0 commit comments

Comments
 (0)