diff --git a/src/Uno.UI/UI/Xaml/Automation/Peers/HyperlinkButtonAutomationPeer.cs b/src/Uno.UI/UI/Xaml/Automation/Peers/HyperlinkButtonAutomationPeer.cs index 5bd1276001f7..edd91d611590 100644 --- a/src/Uno.UI/UI/Xaml/Automation/Peers/HyperlinkButtonAutomationPeer.cs +++ b/src/Uno.UI/UI/Xaml/Automation/Peers/HyperlinkButtonAutomationPeer.cs @@ -1,31 +1,34 @@ -#pragma warning disable 108 // new keyword hiding -#pragma warning disable 114 // new keyword hiding +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +// MUX Reference HyperlinkButtonAutomationPeer_Partial.cpp, tag winui3/release/1.4.2 + +using Microsoft.UI.Composition.Interactions; using Microsoft.UI.Xaml.Controls; -namespace Microsoft.UI.Xaml.Automation.Peers +namespace Microsoft.UI.Xaml.Automation.Peers; + +/// +/// Exposes HyperlinkButton types to Microsoft UI Automation. +/// +public partial class HyperlinkButtonAutomationPeer : ButtonBaseAutomationPeer, Provider.IInvokeProvider { - public partial class HyperlinkButtonAutomationPeer : ButtonBaseAutomationPeer, Provider.IInvokeProvider + public HyperlinkButtonAutomationPeer(HyperlinkButton owner) : base(owner) { - public HyperlinkButtonAutomationPeer(HyperlinkButton owner) : base(owner) - { - } + } - protected override string GetClassNameCore() - { - return "Hyperlink"; - } + protected override string GetClassNameCore() => "Hyperlink"; - protected override AutomationControlType GetAutomationControlTypeCore() - { - return AutomationControlType.Hyperlink; - } + protected override AutomationControlType GetAutomationControlTypeCore() + => AutomationControlType.Hyperlink; - public void Invoke() + public void Invoke() + { + if (!IsEnabled()) { - if (IsEnabled()) - { - (Owner as HyperlinkButton).AutomationPeerClick(); - } + // UIA_E_ELEMENTNOTENABLED + throw new ElementNotEnabledException(); } + + (Owner as HyperlinkButton).AutomationPeerClick(); } }