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

本文关键字:文本 何使用 按钮 启用 | 更新日期: 2023-09-27 18:26:15

我到处找,但没有找到解决方案。

我只想当我点击按钮时,文本框就会启用,这样我们就可以在其中写入。

我试过了:

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

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

控件没有名为"Enabled"的属性。试试这个:
textbox11.IsEnabled = true;

注意"是"。