I need to bind a TextBox that meets two criteria:
- IsEnabled if Text.Length > 0
- IsEnabled if user.IsEnabled
Where user.IsEnabled is pulled from a data source. I was wondering if anyone had a easy method for doing this.
Here is the XAML:
<ContentControl IsEnabled="{Binding Path=Enabled, Source={StaticResource UserInfo}}">
<TextBox DataContext="{DynamicResource UserInfo}" Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=Text, RelativeSource={RelativeSource Self}, Converter={StaticResource LengthToBool}}"/>
</ContentControl>
Since you only need a logical
OR, you just need two Triggers to your each of the properties.Try this XAML:
I set
DataContextto theWindowclass which has aDependencyPropertycalledMyIsEnabled. Obviously you would have to modify for your particularDataContext.Here is the relevant code-behind:
Hope that helps!