Álvaro García
Álvaro García

Reputation: 19366

how can set a property when change one of the many conditions?

I have a button that I want to disabled in some cases. To determinate that, I use the selection of many controls in the view. For simplify in this question, two comboBox.

So the IsEnabled depends on the combiation of the information in this two controls, I need to evaluate the new state when change one of them. How can I do that? I know that I need a multi value converter to determinate if the button is enabled or not, but I don't know how to execute the converter when the selection in one of the combobox is changed.

EDIT:

When I have said before Multi value converter I wanted to say multi binding.

Perhaps I have not been very clear. I want the following:

1.- In the beginning the button is disabled and the two comboBox have not any item selected.

2.- When I selected an item in one of the comboBox, I need to execute the multi binding that is used to set the IsEnabled property of the button.

And repeat the process when I selected a new item in any of the comboBox.

The problem that I have is that I don't know how to say to the button that when I change the selection in any of the comboBox, the button need to execute the multi binding to determinate the value of the IsEnabled property.

Upvotes: 1

Views: 67

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564551

but I don't know how to execute the converter when the selection in one of the combobox is changed.

As long as the values you're binding to are either DependencyProperty values or part of a class that (properly) implements INotifyPropertyChanged, this will happen automatically. You shouldn't need to do anything to update the values.

Just make sure the bound values notify as if they were used directly, and WPF will handle this when using an IMultiValueConverter just fine.

Upvotes: 1

Related Questions