0 Replies - 2542 Views - Last Post: 22 November 2013 - 08:48 PM

#1 markweb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-November 13

Tap not working

Posted 22 November 2013 - 08:48 PM

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 Smile | :)/> .

anyone who can spot anything wrong would very much appreciated

mark

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<int> savedCount = new Setting<int>("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");
 
}
}
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1