End Google Ads 201810 - BS.net 01 --> Hi I have created a windows phone app 7.1 that counts the taps, it has a reset button as well, I have coded it and no errors are showing, the app opens perfectly in the emulator but when you tap the screen no count happens, I have been through the code so many time Im nearly dizzy .

anyone who can spot anything wrong would very much appreciated.

--------------------------

MainPage.xaml.cs

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; namespace PhoneAppSolution{ public partial class MainPage : PhoneApplicationPage { int count = 0; //remember what the user typed for future actuvations or launches: Setting<span class="code-keyword"int/span> savedCount = new Setting<span class="code-keyword"int/span>("SavedCount", 0); // Constructor public MainPage() { InitializeComponent(); } //Handle a tap anywhere on the page (other than button) protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); this.count++; this.CountTextBlock.Text = this.count.ToString("NO"); } //Handle a tap on the button void ResetButton_Click(object sender, RoutedEventArgs e) { this.count = 0; this.CountTextBlock.Text = this.count.ToString("NO"); } protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e){ base.OnNavigatedFrom(e); // Persist state when leaving for any reason (Deactivated or Closing) this.savedCount.Value = this.count; } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){ base.OnNavigatedTo(e); // restore persisted value state: this.count = this.savedCount.Value; this.CountTextBlock.Text = this.count.ToString("NO"); }}}

-----------------------------------------------------------

Setting.cs

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO.IsolatedStorage; namespace PhoneAppSolution{ public class Setting { string name; num value; num defaultValue; bool hasValue; public Setting(string name, num defaultValue) { this.name = name; this.defaultValue = defaultValue; } public num Value { get { //check for cached value if(!this.hasValue) { // try to get value from isolated storage if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue( this.name, out this.value)) { //if this hasn't yet set this.value = this.defaultValue; IsolatedStorageSettings.ApplicationSettings[this.name] = this.value; } this.hasValue = true; } return this.value; } set { //save the value to isolated storage IsolatedStorageSettings.ApplicationSettings[this.name] = value; this.value = value; this.hasValue = true; } } public num DefaultValue { get { return this.DefaultValue; } } // "clear" cached value: public void Force*******() { this.hasValue = false; } }}

--------------------------------------------------------------

MainPage.xaml




Any help really appreciated.

Paddy