【问题标题】:What is the difference between ActionCommand and DelegateCommandActionCommand 和 DelegateCommand 有什么区别
【发布时间】:2014-03-26 05:28:29
【问题描述】:

如果有人能告诉我使用 Expression Blend 和 DelegateCommand 类 (Prism) 中的 ActionCommand 类有什么区别和好处,我将不胜感激?

如果我理解正确,DelegateCommand 支持两个委托,而 ActionCommand 类只支持一个 Execute 委托。还有其他区别吗?在阅读了文档和在线之后,我仍然不太明白使用任何一个都有什么好处。

提前致谢

【问题讨论】:

标签: c# mvvm icommand


【解决方案1】:

DelegateCommand 允许委派命令逻辑,而不是在后面的代码中要求处理程序。它使用委托作为调用目标处理方法的方法。 喜欢

public class DelegateCommand<T> : ICommand
{
    public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
    {
        …
        this.executeMethod = executeMethod;
        this.canExecuteMethod = canExecuteMethod;
        …
    }
…
}

【讨论】:

    猜你喜欢
    • 2012-12-20
    • 2013-06-04
    • 2010-10-02
    • 2011-12-12
    • 2010-09-16
    • 2012-03-14
    • 2012-02-06
    • 2011-02-25
    • 2011-11-22
    相关资源
    最近更新 更多