WPF multitrigger referencing 2 other controls
Posted
by BrettRobi
on Stack Overflow
See other posts from Stack Overflow
or by BrettRobi
Published on 2010-04-05T20:38:02Z
Indexed on
2010/04/05
20:43 UTC
Read the original article
Hit count: 441
I have two CheckBoxes and a TextBox. I want to TextBox to have IsEnabled=False if both CheckBoxes have IsChecked=False. Can I do this with a MultiTrigger? I keep getting errors trying to use the Source property.
I have it working with MultiDataTriggers as you can see below. But have two questions.
1) Is this my only choice? Can I do it with a MultiTrigger?
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=uxDmm , Path=IsChecked}"
Value="False" />
<Condition Binding="{Binding ElementName=uxGpm , Path=IsChecked}"
Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled"
Value="False" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
2) Can I do this outside of the tag? I'm not really sure where Triggers can be applied, most samples do it within Style or DataTemplates, but defining it within a Style is messing up my default look and feel for the TextBox.
© Stack Overflow or respective owner