3 changed files with 80 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace Avalonia.Markup |
||||
|
{ |
||||
|
class AlwaysEnabledDelegateCommand : ICommand |
||||
|
{ |
||||
|
private readonly Delegate action; |
||||
|
|
||||
|
public AlwaysEnabledDelegateCommand(Delegate action) |
||||
|
{ |
||||
|
this.action = action; |
||||
|
} |
||||
|
|
||||
|
public event EventHandler CanExecuteChanged; |
||||
|
|
||||
|
public bool CanExecute(object parameter) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
public void Execute(object parameter) |
||||
|
{ |
||||
|
if (action.Method.GetParameters().Length == 0) |
||||
|
{ |
||||
|
action.DynamicInvoke(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
action.DynamicInvoke(parameter); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue