嗨,我有这个按钮,它在另一个页面的文本框中显示数字1。每当用户单击按钮时,我一直在尝试增加文本框的值。我已经在第一页上将传输的值设置为1。目前,该文本框仅显示为2,因为它获取了传输数据的值,并在单击该按钮时增加到2。
这是按钮的代码,该按钮将数据传输到下一页并将其显示在文本框中。
我希望文本框在用户每次单击按钮时增加。
第1页
private void button_Click(object sender, RoutedEventArgs e)
{
App app = Application.Current as App; // declared the variable "storeValue"in app.cs as an integer.
app.storeValue = 1; //setting the value as 1
}
第2页-将变量显示到文本框的代码
protected override void OnNavigatedTo(NavigationEventArgs e)
{
App app = Application.Current as App;
app.storeValue++;
int totalq = int.Parse(textBox.Text) + app.storeValue;
textBox.Text = totalq.ToString();
}
试试这个
第1页
private void button_Click(object sender, RoutedEventArgs e)
{
App app = Application.Current as App; // declared the variable "storeValue"in app.cs as an integer.
app.storeValue++;
}
第2页-将变量显示到文本框的代码
protected override void OnNavigatedTo(NavigationEventArgs e)
{
App app = Application.Current as App;
//app.storeValue++;
int totalq = int.Parse(textBox.Text) + app.storeValue;
textBox.Text = totalq.ToString();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句