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

As my code, I want to a checkbox - select all function. When I manually click the "select all", I want to execute the SelectAllCommand, but if the checkbox is selected automtically, the CanExecute should return false to me....

I don't how to pass a parameter to CanExecute... How can I perfectly do that ...?

Thanks in advance

1
  • 1
    Why not bind to CheckBox.Command and CheckBox.CommandParameter? Commented Mar 13, 2013 at 2:46

1 Answer 1

1

Well, in your code, you're currently passing a parameter, that parameter just happens to be null. So don't you more accurately want to do

if (this.SelectAllCommand.CanExecute(value)) 

?

Sign up to request clarification or add additional context in comments.

2 Comments

yes, I know, but I have to declare a variable, e.g. bool isAuto to control ? and then pass the variable to CanExecute() ? is that a good code style ... ? thanks :)
Sorry, I'm not sure what you mean. Perhaps some more explanation would be helpful.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.