PowerToys/Wox/ViewModel/BaseViewModel.cs
bao-qian 320f78b31b Remove redundant code
1. remove this
2. auto property should be only 1 line
3. misc
4. part of refactoring for PR #494
2016-02-21 18:46:04 +00:00

51 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Wox.ViewModel
{
public class BaseViewModel : INotifyPropertyChanged
{
protected void OnPropertyChanged(string propertyName)
{
if (null != PropertyChanged)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
public class RelayCommand : ICommand
{
private Action<object> _action;
public RelayCommand(Action<object> action)
{
_action = action;
}
public virtual bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public virtual void Execute(object parameter)
{
if (null != _action)
{
_action(parameter);
}
}
}
}