2012-04-09 24 views
-2

我在頁面的最後一行的值的錯誤。程序所做的是計算您點擊屏幕上的點擊次數。在Windows Phone應用程序中的值錯誤

請幫幫我。

我試圖通過添加女貞爲整數,我認爲我解決它以這種方式來增加價值作爲整數和一切,但什麼也沒發生前值有一個與SAVECOUNT問題,那麼我解決它。

你,我要與使用的東西添加一些東西?

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; 
     } 
    } 
} 
+1

那麼你有什麼異常?你如何保存savedCount字段? – gbanfill 2012-04-09 12:11:41

+0

savedCount具有任何名爲value的屬性? – TutuGeorge 2012-04-09 12:18:45

+0

我想要的所有想法是統計你點擊屏幕的應用程序的數量 – 2012-04-09 13:01:31

回答

1

savedCountint。它沒有value屬性或字段。只是使用

this.savedCount = this.count 

雖然我懷疑它會給你你後來的結果。你可能想讓savedCount成爲一個靜態的

相關問題