在WPF中,如何将参数传递给ICommand.CanExecute()

时间:2013-03-13 02:37:59

标签: c# wpf

public bool SelectAll
    {
        get { return this.Get<bool>("SelectAll"); }
        set 
        {
            this.Set<bool>("SelectAll", value);
            if (this.SelectAllCommand.CanExecute(null))
                this.SelectAllCommand.Execute(value);
        }
    }

作为我的代码,我想要一个复选框 - 选择所有功能。 当我手动点击“全选”时,我想执行SelectAllCommand,但是如果自动选择了复选框,CanExecute应该向我返回false ....

我不知道如何将参数传递给CanExecute ......我怎么能完美地做到这一点......?

提前致谢

1 个答案:

答案 0 :(得分:1)

好吧,在您的代码中,您当前正在传递一个参数,该参数恰好为null。所以你不想更准确地想做什么

if (this.SelectAllCommand.CanExecute(value))