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