Disable button in WPF?

后端 未结 5 583
一整个雨季
一整个雨季 2020-12-05 16:46

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?

5条回答
  •  清歌不尽
    2020-12-05 17:44

    You could subscribe to the TextChanged event on the TextBox and if the text is empty set the Button to disabled. Or you could bind the Button.IsEnabled property to the TextBox.Text property and use a converter that returns true if there is any text and false otherwise.

提交回复
热议问题