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?
I know this isn't as elegant as the other posts, but it's a more straightforward xaml/codebehind example of how to accomplish the same thing.
Xaml:
CodeBehind:
Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Button01.IsEnabled = False
Button01.Content = "I am Disabled"
End Sub
Private Sub TextBox01_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles TextBox01.TextChanged
If TextBox01.Text.Trim.Length > 0 Then
Button01.IsEnabled = True
Button01.Content = "I am Enabled"
Else
Button01.IsEnabled = False
Button01.Content = "I am Disabled"
End If
End Sub