在WPF中,如何将参数传递给iccommand . canexecute()

本文关键字:iccommand canexecute 参数传递 WPF | 更新日期: 2023-09-27 18:03:32

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…我怎样才能完美地做到……?

Thanks in advance

在WPF中,如何将参数传递给iccommand . canexecute()

在你的代码中,你正在传递一个参数,这个参数恰好是空的。所以你是不是更准确地想做

if (this.SelectAllCommand.CanExecute(value))

?