diff --git a/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs index 4ea950df7e..86cd0d5b14 100644 --- a/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs @@ -19,9 +19,16 @@ namespace Avalonia.Controls.Automation.Peers return AutomationControlType.Text; } - override protected string GetNameCore() + override protected string? GetNameCore() { - return AccessText.RemoveAccessKeyMarker(((Label)Owner).Content as string) ?? string.Empty; + var content = ((Label)Owner).Content as string; + + if (string.IsNullOrEmpty(content)) + { + return base.GetNameCore(); + } + + return AccessText.RemoveAccessKeyMarker(content) ?? string.Empty; } } }