WPF Customize DelegateCommand
public class delcmd : icommand
{
private readonly predicate<object> _canexecute;
private readonly action<object> _execute;
public event eventhandler canexecutechanged
{
add { commandmanager.requerysuggested += value; }
remove { commandmanager.requerysuggested -= value; }
}
public delcmd(action<object> execute):this(execute,null)
{
}
public delcmd(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);
}
}
上一篇: Java开发笔记(一百零九)XML报文的定义和解析
下一篇: 我一句也没听见
推荐阅读
-
WPF通过线程使用ProcessBar的方法详解
-
WPF实现类似360安全卫士界面的程序源码分享
-
WPF DataGrid显示MySQL查询信息,且可删除、修改、插入 (原发布 csdn 2018-10-13 20:07:28)
-
WPF DispatcherTimer一些个人看法 (原发布 csdn 2017-04-25 19:12:22)
-
wpf 单例模式和异常处理 (原发布 csdn 2017-04-12 20:34:12)
-
一个基于Net Core3.0的WPF框架Hello World实例
-
如何在双向绑定的Image控件上绘制自定义标记(wpf)
-
WPF布局容器
-
[WPF自定义控件库] 给WPF一个HyperlinkButton
-
WPF中button按钮同时点击多次触发click解决方法