[英]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 这是XAML代码
<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". 该控件没有名为“ Enabled”的属性。 Try this: 尝试这个:
textbox11.IsEnabled = true;
Note the "Is". 注意“是”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.