简体   繁体   中英

How to enable/disable a textbox with a button

I looked everywhere for this and didnt find a solution.

All I want is that when I click the button, the textbox becomes enabled, so we can write in it.

I tried :

public void button11_Click(object sender, RoutedEventArgs e)
    {

     textbox11.Enabled = true; 

    }

and this is the xaml code

<TextBox Name="textbox11" IsEnabled="False".....>

but obviously it doesnt work. The error I get :

'System.Windows.Controls.TextBox' does not contain a definition for 'Enabled' and no extension method 'Enabled' accepting a first argument of type 'System.Windows.Controls.TextBox' could be found (are you missing a using directive or an assembly reference?)

The control doesn't have a property called "Enabled". Try this:

textbox11.IsEnabled = true;

Note the "Is".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM