Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在WPF中,如何向ICommand.CanExecute()传递参数 public bool SelectAll { 获取{返回这个。获取(“SelectAll”);} 设置 { 设置(“SelectAll”,值); if(this.SelectAllCommand.CanExecute(null)) 此.SelectAllCommand.Execute(值); } }_C#_Wpf - Fatal编程技术网

C# 在WPF中,如何向ICommand.CanExecute()传递参数 public bool SelectAll { 获取{返回这个。获取(“SelectAll”);} 设置 { 设置(“SelectAll”,值); if(this.SelectAllCommand.CanExecute(null)) 此.SelectAllCommand.Execute(值); } }

C# 在WPF中,如何向ICommand.CanExecute()传递参数 public bool SelectAll { 获取{返回这个。获取(“SelectAll”);} 设置 { 设置(“SelectAll”,值); if(this.SelectAllCommand.CanExecute(null)) 此.SelectAllCommand.Execute(值); } },c#,wpf,C#,Wpf,作为我的代码,我想要一个复选框-选择所有函数。 当我手动单击“全选”时,我想执行SelectAllCommand,但如果自动选中该复选框,则CanExecute应向我返回false 我不知道如何将参数传递给CanExecute。。。我怎样才能完美地做到 提前感谢好吧,在您的代码中,您当前正在传递一个参数,该参数恰好为空。所以你不想更准确地说吗 public bool SelectAll { get { return this.Get<bool>("Select

作为我的代码,我想要一个复选框-选择所有函数。 当我手动单击“全选”时,我想执行SelectAllCommand,但如果自动选中该复选框,则CanExecute应向我返回false

我不知道如何将参数传递给CanExecute。。。我怎样才能完美地做到


提前感谢

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

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

为什么不绑定到
复选框。Command
复选框。CommandParameter
?是的,我知道,但我必须声明一个变量,例如bool isAuto来控制?然后将变量传递给CanExecute()?这是一种好的代码风格吗?谢谢:)对不起,我不知道你的意思。也许更多的解释会有所帮助。
if (this.SelectAllCommand.CanExecute(value))