WPF中ICommand接口 的一个设计问题
2010-01-27 19:00
555 查看
publicinterfaceICommand { //Summary: //Occurswhenchangesoccurthataffectwhetherornotthecommandshouldexecute. eventEventHandlerCanExecuteChanged;
boolCanExecute(objectparameter); voidExecute(objectparameter); }
//Definesanobjectthatknowshowtoinvokeacommand.
publicinterfaceICommandSource
{
//Summary:
//Getsthecommandthatwillbeexecutedwhenthecommandsourceisinvoked.
ICommandCommand{get;}
objectCommandParameter{get;}
IInputElementCommandTarget{get;}
}
MSDN:
Normally,acommandsourcewilllistentotheCanExecuteChangedeventonthecommand.Thisinformsthecommandsourcewhenconditionschangeonthecommandtarget,suchaslossofkeyboardfocus.Thecommandsourcecanthenquerythecommandusingthe CanExecutemethod.
按照MSDN中的解释,当CanExecuteChanged事件发生时,ICommandSource会调用ICommand的CanExecute方法来检测是否可以执行命令。如果是这样,这里的这个事件名取为:类似“CanExecuteConditionChanged”不是更好吗?
因为CanExecuteChanged发生,使用者的第一感觉就是CanExecute从false变到true或者由true变到false了。
关于这个设计问题,我想不出原因,所以希望高人解释下。:)
另外,还有一个小问题,MSDN中说到:
IntheWindowsPresentationFoundation(WPF)commandingsystem,theCommandTargetpropertyonaICommandSourceisonlyapplicablewhentheICommandisaRoutedCommand.IftheCommandTargetissetonaICommandSourceandthecorrespondingcommandisnotaRoutedCommand,thecommandtargetisignored.
那么,设计这个属性会不会有点多余?虽然我觉得加上也是好的。
相关文章推荐
- 基于wpf的相关设计问题-Command的使用
- 一个 C 接口设计的问题
- 一个 C 接口设计的问题
- 基于wpf的相关设计问题-Command的使用
- 一个低级的问题,设计生产基带芯片的难点在哪呢?高手进!
- 调用淘宝订单接口想到的一个问题
- Prototype功能预览十三:一个注解完成更加规范的API版本管理-极大减少dubbo框架频繁修改接口问题
- WPF布局控件AvalonDock介绍以及应用中遇到的一个问题
- [基础题] * 9.(*)设计一个Student接口,以一维数组存储一个班级的学生姓名。
- 程序猿基于解决复杂问题设计的一个APP
- Java学习笔记--解决一个类实现多个接口的问题
- 组合设计模式,解决struts只能有一个资源文件的问题
- 只有一个属性的维度设计问题
- winform设计一个登录界面和修改密码的界面-自动切换窗体(问题[已解] 望一起讨论)(技术改变世界-cnblog)
- 第一章 设计一个简单的web service接口
- 记录一个设计的问题
- 架构设计:进程还是线程?是一个问题!
- 组件接口(API)设计指南[1]-要考虑的问题
- 架构设计:进程还是线程?是一个问题!
- Delphi 设计模式:《HeadFirst设计模式》Delphi代码---模式小结之一个叫声接口和几只鸭子