diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index 0e8a765e57..dc65df2584 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; +using System.Linq; using System.Windows.Input; using Avalonia.Data; using Avalonia.Input; @@ -251,8 +252,9 @@ namespace Avalonia.Controls IsPressed = false; e.Handled = true; - if (ClickMode == ClickMode.Release && - (IsPointerOver || new Rect(Bounds.Size).Contains(e.GetPosition(this)))) + var hittest = VisualRoot?.Renderer?.HitTest(e.GetPosition(VisualRoot), VisualRoot, null); + + if (ClickMode == ClickMode.Release && hittest?.Any(v => v == this) == true) { OnClick(); } @@ -262,9 +264,9 @@ namespace Avalonia.Controls protected override void UpdateDataValidation(AvaloniaProperty property, BindingNotification status) { base.UpdateDataValidation(property, status); - if(property == CommandProperty) + if (property == CommandProperty) { - if(status?.ErrorType == BindingErrorType.Error) + if (status?.ErrorType == BindingErrorType.Error) { IsEnabled = false; }