[英]C# WPF - How to change a textblock when you press a button
我正在尝试使其当前,以便当我按让我说Button1时,一个文本块将更改为特定的值。 我如何做到这一点是这样的:
public MainWindow()
{
InitializeComponent();
textResult.Text = currentValue.ToString();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
currentValue = 1;
}
textResult是文本块。
如果我启动我的程序,它不会改变。
我究竟做错了什么?
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
currentValue = 1;
textResult.Text = currentValue.ToString();
}
您未设置TextBox的text属性,因此必须执行以下操作:
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
currentValue = 1;
textResult.Text = currentValue.ToString();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.