Browse Source
Merge pull request #2298 from donandren/prs/buttonimpr
Check command canexecute before execute for button/menu command
pull/2313/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
2 deletions
-
src/Avalonia.Controls/Button.cs
-
src/Avalonia.Controls/MenuItem.cs
|
|
|
@ -217,7 +217,7 @@ namespace Avalonia.Controls |
|
|
|
var e = new RoutedEventArgs(ClickEvent); |
|
|
|
RaiseEvent(e); |
|
|
|
|
|
|
|
if (Command != null) |
|
|
|
if (!e.Handled && Command?.CanExecute(CommandParameter) == true) |
|
|
|
{ |
|
|
|
Command.Execute(CommandParameter); |
|
|
|
e.Handled = true; |
|
|
|
|
|
|
|
@ -287,7 +287,7 @@ namespace Avalonia.Controls |
|
|
|
/// <param name="e">The click event args.</param>
|
|
|
|
protected virtual void OnClick(RoutedEventArgs e) |
|
|
|
{ |
|
|
|
if (Command != null) |
|
|
|
if (!e.Handled && Command?.CanExecute(CommandParameter) == true) |
|
|
|
{ |
|
|
|
Command.Execute(CommandParameter); |
|
|
|
e.Handled = true; |
|
|
|
|