2016-02-18 19:30:36 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
2016-02-27 08:09:12 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2016-02-18 19:30:36 +08:00
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace Wox.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class BaseViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
|
2016-02-27 08:09:12 +08:00
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
2016-02-18 19:30:36 +08:00
|
|
|
|
{
|
2016-02-23 05:47:10 +08:00
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
2016-02-18 19:30:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|