每次用户单击 windows phone 中的按钮时,如何增加文本框的值?
How to increment value of textbox each time user clicks the button in windows phone?
您好,我有这个按钮,它在不同页面的文本框中显示数字 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();
}
您好,我有这个按钮,它在不同页面的文本框中显示数字 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();
}