DataTrigger to make WPF Button inactive until TextBox has value
- by JohnB
I want the Button control's property to be IsEnabled="False" until a value is entered into a TextBox in the Window.
Code so far:
<Button
Content="Click Me"
Name="ClickMe"
VerticalAlignment="Top"
Click="ClickMe_Click">
<Button.Style>
<Style>
<Style.Triggers>
<DataTrigger
Binding="{Binding ElementName=textBox, Path=Length}"
<!-- or even: Binding="{Binding Path=textBox.Length}" -->
Value="0">
<Setter
Property="Button.IsEnabled"
Value="false" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Also, is it possible to have this Button control's IsEnabled property be based on 3 different TextBox controls all having values?