Detecting and handling multi-touch events in Windows Phone 7 applications
This article provides a simple code snippet showing how to capture multi-touch events on Windows Phone 7 using touch framereported .This event will active for touch activity across the entire application.The Touch framework has two primary concepts: the TouchPoint object and the FrameReported event.The TouchPoint object stores data related to a single touch point. The first touch point that is fired to the application is called the primary touch point. The object has two important properties: Position and Action. The Action property stores the current action state, such as Up, Down, and Move. The Up and Down actions are similar to the mouse's MouseLeftButtonUp and MouseLeftButonDown events. The Move action is the transition action that is constantly called until the user releases the Touch Point, which also invokes the Up action. The TouchFrameEventArgs argument has methods of getting information about touch points. You can get the current touch points by calling the GetPrimaryTouchPoint and GetTouchPoint methods.GetPrimaryTouchPoint is called to get single-touch data,If multiple fingers are pressed on the screen, GetPrimaryTouchPoint returns data about the first finger that makes contact with the screen.
Article Metadata
Tested with
Compatibility
Article
Basic Implementation code
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;
namespace Multtouch
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Touch.FrameReported += Touch_FrameReported;//touch/multi-touch event.
}
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
TouchPointCollection points = e.GetTouchPoints(this);
int numPoints =(from p in points where p.Action != TouchAction.Up select p).Count();
/*
LINQ query to set the value of numPoints.Here I filter out the touch points whose Action proprty is "UP" because the counting of touch points does not tell us howmany fingers are currently in contact with the screen.
*/
MessageBox.Show(numPoints.ToString());
}
}
}
Summary
As the touch event get raised for touch activity across the entire application you must unsubscribe FrameReported handlers being invoked when they don’t need,forgetting to detach from this event can cause other problems.Windows Phone guaranteed to support four simultaneous touch points.


Hamishwillee - So, where is the description?
Hi sreeraj vr
Your description of the article says "I am going to describe a very simple application I’ve developed while playing around with multi-touch functionality in Windows Phone 7." However all I see is a code dump - this isn't an application and there isn't any description.
To make this useful you would need to describe what the application is supposed to do, why it is useful, provide links to any source references you learned to created it (e.g. on MSDN) and also any tricks/tips associated with using this code - ie what if you want to detect multi-touch events on a map control as opposed to over the top of some other control. That way not only can people easily use your code, but they can work out when the code is not so useful, and extend it to other use cases. Does that make sense?
Even better, if you could compare and contrast the handling of touch events and gestures with Qt and Windows Phone, showing the differences.
Regards
Hamishhamishwillee 08:13, 10 April 2012 (EEST)