I have a Button and a TextBox in my WPF app. How can I make the Button not enabled until the user enters some text in the TextBox?
This should do it:
<StackPanel> <TextBox x:Name="TheTextBox" /> <Button Content="Click Me"> <Button.Style> <Style TargetType="Button"> <Setter Property="IsEnabled" Value="True" /> <Style.Triggers> <DataTrigger Binding="{Binding Text, ElementName=TheTextBox}" Value=""> <Setter Property="IsEnabled" Value="False" /> </DataTrigger> </Style.Triggers> </Style> </Button.Style> </Button> </StackPanel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With