diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs index e96b7aff08d..3cadc7243a6 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs @@ -157,7 +157,8 @@ private Window CreateSampleWindow() (button = new Button { HorizontalAlignment = HorizontalAlignment.Center, - Content = "Click to close" + Content = "Click to close", + IsDefault = true }) } }, diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index 8537c9acbcf..7e24471bde6 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -550,6 +550,7 @@ private void RootDefaultKeyDown(object sender, KeyEventArgs e) if (e.Key == Key.Enter && IsVisible && IsEnabled) { OnClick(); + e.Handled = true; } } @@ -563,6 +564,7 @@ private void RootCancelKeyDown(object sender, KeyEventArgs e) if (e.Key == Key.Escape && IsVisible && IsEnabled) { OnClick(); + e.Handled = true; } }