2016-02-18 19:30:36 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace Wox.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class RelayCommand : ICommand
|
|
|
|
|
{
|
2016-02-12 14:21:12 +08:00
|
|
|
|
private Action<object> _action;
|
2016-02-18 19:30:36 +08:00
|
|
|
|
|
2016-02-12 14:21:12 +08:00
|
|
|
|
public RelayCommand(Action<object> action)
|
2016-02-18 19:30:36 +08:00
|
|
|
|
{
|
2016-02-21 23:42:37 +08:00
|
|
|
|
_action = action;
|
2016-02-18 19:30:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool CanExecute(object parameter)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
|
|
|
|
|
|
public virtual void Execute(object parameter)
|
|
|
|
|
{
|
2016-02-23 05:47:10 +08:00
|
|
|
|
_action?.Invoke(parameter);
|
2016-02-18 19:30:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|