Is it possible to bind to a property using logical operators? Take for instance my earlier question of binding to the IsEnabled property of a button. I was using...
<Button Name="btnUpdate" Content="Update" Click="btnUpdate_Click" TabIndex="3" IsEnabled="{Binding UpdateAvailable}" ></Button>Say I want my binding to be dependent on two properties. So, not only does it evaluate UpdateAvailable (bool) but it looks at IsConnected (bool) as well. So, the two should be compared using a logical And.
Also, take this a bit further and say I want to utilize a value that is not a boolean value. For example, maybe there is a text field that should evaluate to true if it contains a particular string, otherwise it evaluates to false.

1 answers
On the first point, I'm fairly sure that you can only bind to a single property and not to a combination of properties.
Of course, there'd be nothing to stop you creating a separate property which returned the result of AND'ing two other properties. However, the new property would be read-only as it's difficult to see what you could put in the setter and how therefore you could achieve two-way binding.
On the second point, you might be able to do something by creating a 'converter' class to be used in the binding which implemented IValueConverter and which would convert between your bool and string values. However, it's so complicated to do this that I think you'd find it far easier to forget about binding and maintain the association between the properties using manually written code.
answered one year ago by:
17279