Assuming that you want to disable the controls when the
first item in the
ComboBox
is selected, then binding to
SelectedIndex
will work:
<TextBox Name="credentials" IsEnabled="{Binding ElementName=account_type, Path=SelectedIndex}" />
<PasswordBox Name="password" IsEnabled="{Binding ElementName=account_type, Path=SelectedIndex}" />
This is because the binding will try to convert the value to a
Boolean
;
0
will be converted to
false
, and anything else will be converted to
true
.
For a more robust solution, you would need to bind to the
SelectedItem
, and provide a converter to turn the value of the item into a
Boolean
.
Alternatively, if you use MVVM, you could expose a
CredentialEntryEnabled
property with the relevant logic. When the account type property changed, you would raise the
PropertyChanged
event for the
CredentialEntryEnabled
property as well.