【发布时间】:2014-03-26 05:28:29
【问题描述】:
如果有人能告诉我使用 Expression Blend 和 DelegateCommand 类 (Prism) 中的 ActionCommand 类有什么区别和好处,我将不胜感激?
如果我理解正确,DelegateCommand 支持两个委托,而 ActionCommand 类只支持一个 Execute 委托。还有其他区别吗?在阅读了文档和在线之后,我仍然不太明白使用任何一个都有什么好处。
提前致谢
【问题讨论】:
如果有人能告诉我使用 Expression Blend 和 DelegateCommand 类 (Prism) 中的 ActionCommand 类有什么区别和好处,我将不胜感激?
如果我理解正确,DelegateCommand 支持两个委托,而 ActionCommand 类只支持一个 Execute 委托。还有其他区别吗?在阅读了文档和在线之后,我仍然不太明白使用任何一个都有什么好处。
提前致谢
【问题讨论】:
DelegateCommand 允许委派命令逻辑,而不是在后面的代码中要求处理程序。它使用委托作为调用目标处理方法的方法。 喜欢
public class DelegateCommand<T> : ICommand
{
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
{
…
this.executeMethod = executeMethod;
this.canExecuteMethod = canExecuteMethod;
…
}
…
}
【讨论】: