Assuming you are using a view model such as ViewModel, you should bind data directly instead of user interface elements.
<Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding FirstName}" Value="{x:Null}" /> <Condition Binding="{Binding MiddleName}" Value="{x:Null}" /> <Condition Binding="{Binding LastName}" Value="{x:Null}" /> </MultiDataTrigger.Conditions> <Setter Property="Button.IsEnabled" Value="False" /> </MultiDataTrigger> </Style.Triggers>
However, if you use the presentation model, you can always add the bool property "EnableSave" and handle all the presentation logic there, and not in the view itself.
Update
As you can see from the comments, I mistakenly set this to enable Button when any TextBox has a value, but the requirement is that Button be turned on when all TextBox es have values.
Conceptually, all you have to do is change the conditions - instead of "false if all conditions are false", we want "true if all conditions are true."
The trap is that there is no way to say "not null" in XAML - in no way without an IValueConverter , that is. I would create a NullToBoolConverter that returns false for null and true for != null .
For such a converter:
<Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding FirstName, Converter={StaticResource NullToBoolConverter}}" Value="True" /> <Condition Binding="{Binding MiddleName, Converter={StaticResource NullToBoolConverter}}" Value="True" /> <Condition Binding="{Binding LastName, Converter={StaticResource NullToBoolConverter}}" Value="True" /> </MultiDataTrigger.Conditions> <Setter Property="Button.IsEnabled" Value="True" /> </MultiDataTrigger> </Style.Triggers>
Jay
source share