using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; namespace WpfApp55.ViewModel
{
public class VM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propName));
}
} private DelegateCommand UCCmdValue;
public DelegateCommand UCCmd
{
get
{
if(UCCmdValue==null)
{
UCCmdValue = new DelegateCommand(UCCmdExecuted, UCCmdCanExecute);
}
return UCCmdValue;
}
} private bool UCCmdCanExecute(object obj)
{
return true;
} private void UCCmdExecuted(object obj)
{
MessageBox.Show("You had clicked the customized button!");
}
}
}
  public class DelegateCommand : ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute; public event EventHandler CanExecuteChanged; public DelegateCommand(Action<object> execute)
: this(execute, null)
{
} public DelegateCommand(Action<object> execute,
Predicate<object> canExecute)
{
_execute = execute;
_canExecute = canExecute;
} public bool CanExecute(object parameter)
{
if (_canExecute == null)
{
return true;
} return _canExecute(parameter);
} public void Execute(object parameter)
{
_execute(parameter);
} public void RaiseCanExecuteChanged()
{
if (CanExecuteChanged != null)
{
CanExecuteChanged(this, EventArgs.Empty);
}
}
}

最新文章

  1. Ubuntu下deb文件及tgz文件安装
  2. Windows 安装Kafka
  3. JS原生效果瀑布流布局的实现(一)
  4. [lintcode] Binary Tree Maximum Path Sum II
  5. haskell中的monad
  6. stardict
  7. C#Lambda表达式学习日记
  8. hdu5072(鞍山regional problem C):容斥,同色三角形模型
  9. delphi 文件夹权限设置(执行一个小脚本的笨办法)
  10. 分析Sizzle引擎
  11. js登录,回车登录
  12. 第十五节:深入理解async和await的作用及各种适用场景和用法
  13. lavarel 中间件
  14. 学习 MeteoInfo二次开发教程(一)
  15. sqlite读写
  16. POJ 2462 / HDU 1154 Cutting a Polygon
  17. iframe跨域与session失效问题
  18. 【C#】遍历List列表的同时,移除访问到的元素
  19. Vue学习笔记之Webpack介绍
  20. AE+C#实现:在SceneControl里打开和保存

热门文章

  1. spring boot2 修改默认json解析器Jackson为fastjson
  2. .NET Core使用RabbitMQ
  3. spring boot 2 + shiro 实现权限管理
  4. 智能家居手势识别,只需百度AI即可搞定
  5. 我用 Python 破解了同事的加密压缩包!
  6. canvas的介绍
  7. JavaBean动态添加删除属性
  8. Linux使用alias自定义命令自定义快捷键
  9. IDEA 如何自动导入(import)
  10. Mysql字符串截取_获取指定字符串中的数据