如何使用按钮启用/禁用文本框

时间:2015-12-09 21:08:14

标签: c# textbox isenabled

我到处寻找这个并没有找到解决方案。

我想要的只是当我点击按钮时,文本框变为启用状态,因此我们可以在其中书写。

我试过了:

public void button11_Click(object sender, RoutedEventArgs e)
    {

     textbox11.Enabled = true; 

    }

这是xaml代码

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

但显然它不起作用。我得到的错误:

'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?)

1 个答案:

答案 0 :(得分:6)

控件没有名为&#34;已启用&#34;的属性。试试这个:

textbox11.IsEnabled = true;

注意&#34; Is&#34;。