Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 06:00, 2 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Detecting and handling multi-touch events in Windows Phone 7 applications

From Wiki
Jump to: navigation, search

Needs-update.pngThis article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.

Reasons: hamishwillee (30 May 2013)
The article is incomplete. 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. Jerry (see comments) also found it inconsistent.

This article provides a simple code snippet showing how to capture multi-touch events on Windows Phone 7 using touch framereported .This event will activate 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 within 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 then invokes the Up action. The TouchFrameEventArgs argument has methods for 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. Note: If multiple fingers are pressed on the screen, GetPrimaryTouchPoint returns data about the first finger that makes contact with the screen.

WP Metro Icon UI.png
SignpostIcon WP7 70px.png
Article Metadata
Tested with
SDK: Windows Phone SDK 7.1
Devices(s): Nokia Lumia 800
Platform(s): Windows Phone 7.5 (Mango)
Windows Phone 7.5
Created: sreerajvr (06 Apr 2012)
Last edited: hamishwillee (02 Jul 2013)

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()
protected override void OnNavigatedTo(NavigationEventArgs 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.



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.

This page was last modified on 2 July 2013, at 06:00.
50 page views in the last 30 days.