Make Button enabled/disabled depending on the TextBox Text property in WPF?

Viewed 40646

I was looking for code through google that enables and disables a button based on the text property from a textbox. If the textbox has some text then the button should be enabled or otherwise button should be disabled.

I got some code but code in xaml but no c#. I am not being able to understand how it works.

Please help me to understand the behaviour of the following code:

<TextBox Name="txtName" Width="100" Height="30"></TextBox>

<Button Content="Add Name " Width="100" Height="30" 
  IsEnabled="{Binding ElementName=txtName, Path=Text.Length, Mode=OneWay}"/>

How is the IsEnabled button property working? How is true and false set to the IsEnabled property? What is Path? How does it work?

5 Answers
Related