1、定义接口
interface IView
{
// 属性
Boolean IsChanged {
get; set; }
// 方法
void Clear();
}
2、定义命令
public class ClearCommand : ICommand
{
//当命令状态改变时被激发
public event EventHandler CanExecuteChanged;
//用于判断命令是否可执行
public bool CanExecute(object parameter)
{
throw new NotImplementedException();
}
// 命令执行,带相关业务逻辑
public void Execute(object parameter)
{
IView view = parameter as IView;
if (view != null)
{
view.Clear();
}<