27 lines
656 B
C#
27 lines
656 B
C#
using System;
|
|
using System.Windows.Input;
|
|
|
|
namespace unison
|
|
{
|
|
public class DelegateCommand : ICommand
|
|
{
|
|
public Action CommandAction { get; set; }
|
|
public Func<bool> CanExecuteFunc { get; set; }
|
|
|
|
public void Execute(object parameter)
|
|
{
|
|
CommandAction();
|
|
}
|
|
|
|
public bool CanExecute(object parameter)
|
|
{
|
|
return CanExecuteFunc == null || CanExecuteFunc();
|
|
}
|
|
|
|
public event EventHandler CanExecuteChanged
|
|
{
|
|
add { CommandManager.RequerySuggested += value; }
|
|
remove { CommandManager.RequerySuggested -= value; }
|
|
}
|
|
}
|
|
} |