title: How to do touch input in C#?
body: <p>Basically, a simple app that when a user touches the screen, the counter on the screen increments. I have no experience whatsoever with touch inputs or have any knowledge of how to construct one properly. As far as what methods or objects I'm supposed to use, I know nothing. With a button, the touch is automatically registered. So, I want to do likewise with the screen on Windows Phone 8 using Visual Studio 2013. So far, this is the C# code I have so far with an image of what it looks like on mobile display:</p>
  
  <pre><code>public partial class MainPage : PhoneApplicationPage
  {
      int taps = 0; // create var to detect number of times, user touches the screen
  
      // Constructor
      public MainPage()
      {
          InitializeComponent();
      }
  
      // method to register the touch as the finger is placed on the screen
      private void Canvas_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
      {
          //Canvas c = sender as Canvas;
      }
  
      //method register the touch as the finger is lifting up from the screen
      private void Canvas_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
      {
          //Canvas c = sender as Canvas;
          taps++;
          counter.Text = taps.ToString(); //convert var from int to string
      }
  
      //method register the touch as the finger leaves the area of the screen
      private void Canvas_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
      {
          //Canvas c = sender as Canvas;
          MessageBox.Show("You left the screen without lifting your finger. That does not count as a tap!", "Caution!", MessageBoxButton.OK);
      }
  
      // method to reset the counter to zero when button is pressed and released
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          taps = 0; // reset the count
          counter.Text = taps.ToString(); // convert var from int to string
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ST4xp.jpg" alt="Windows Phone 8 Display"></p>