我在页面的最后一行有错误。该程序的作用是计算您在屏幕上点击了多少次点击。
请帮帮我。
我试图将值添加为整数,但是在使用savecount存在问题之前没有发生任何事情然后我通过添加一个privet作为整数修复它我认为我以这种方式解决它。
你有什么东西我必须添加使用的东西吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
using System.Windows.Threading;
namespace TapToCount
{
public partial class MainPage : PhoneApplicationPage
{
private int count;
private int savedCount;
// Constructor
public MainPage()
{
InitializeComponent();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
this.count++;
this.CountTextBlock.Text = this.count.ToString("N0");
}
private void ResetButton_Click(object sender, RoutedEventArgs e)
{
this.count = 0;
this.CountTextBlock.Text = this.count.ToString("N0");
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
// Persist state when leaving for any reason (Deactivated or Closing):
this.savedCount.value= this.count;
}
}
}
答案 0 :(得分:1)
savedCount
是int
。它没有value
属性或字段。只需使用
this.savedCount = this.count
虽然我怀疑它会给你你之后的结果。您可能希望savedCount
成为静态