Silverlight 3 Quick Tip: Multitouch support on Windows 7 - DevCorner

Silverlight 3 Quick Tip: Multitouch support on Windows 7

Silverlight 3 supports Multitouch on Windows 7.

Touch class –provides input information and resides in System.Windows.Input namespace

“FrameReported” event - fired when touch action occurs. Event arguments provide the following info:

  • Timestamp: identify the touch event by time
  • GetTouchPoints function (over specific UI Element)
  • GetPrimaryTouchPoint function (over specific UIElement)
  • SuspendMousePromotionUntilTouchUp function
  • GetTouchPoints returns TouchPointCollection

In TouchPointCollection first point in the collection is the PrimaryPoint. Each member in collection is TouchPoint. TouchPoint provides following info:

  • Position
  • Size
  • TouchDevice
  • Action

Action is from TouchAction enumeration

  • Up
  • Down
  • Move

TouchDevice provides the following info

  • Id: identification provided by operation system
  • DirectlyOver: topmost UIElement under the point

Sample code for getting touch points and simple manipulation:

//Somewhere in code – subscription for touch events:
Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);

When event arrives:

void Touch_FrameReported(object sender, TouchFrameEventArgs e)
    {
      TouchPointCollection points = e.GetTouchPoints(null);
      TouchPoint primaryPoint = e.GetPrimaryTouchPoint(null);

      if (null != primaryPoint)
      {
        if (primaryPoint.Action == TouchAction.Down)
          e.SuspendMousePromotionUntilTouchUp();

        switch (primaryPoint.Action)
        {
          case TouchAction.Down:
            //Business logic here...
            break;

          case TouchAction.Up:
            //Business logic here...
            break;

          case TouchAction.Move:
            //Business logic here...
            break;
        }
      }

Now you application responds for touch events (if you lucky owned of touch-enabled computer) running Windows 7 :)

 

Enjoy,

Alex

Published Friday, July 10, 2009 10:24 AM by Alex Golesh

Comments

# Silverlight 3 Quick Tips

Pingback from  Silverlight 3 Quick Tips

Saturday, July 11, 2009 12:06 PM by Silverlight 3 Quick Tips

# 30 grandes post y tutoriales de Silverlight 3 y Blend 3

AdamKinney , nos ha puesto un post con los 30 mejores posts de Silverlight y Blend 3, aqui os dejo el

Tuesday, July 21, 2009 8:33 AM by Blog de Oskar Alvarez

# 30 grandes post y tutoriales de Silverlight 3 y Blend 3 at Comunidad Gunet M??xico

Pingback from  30 grandes post y tutoriales de Silverlight 3 y Blend 3 at Comunidad Gunet M??xico

# Beat and Byte » 30 grandes post y tutoriales de Silverlight 3 y Blend 3

Pingback from  Beat and Byte » 30 grandes post y tutoriales de Silverlight 3 y Blend 3

# 30 Great Posts and Tutorials on Silverlight and Blend 3

I’ve been tracking content that’s been posted since the Silverlight and Expression 3 launch and there

Tuesday, August 04, 2009 2:42 AM by Microsoft Weblogs

# 30 Great Posts and Tutorials on Silverlight and Blend 3 « Adam Kinney

Pingback from  30 Great Posts and Tutorials on Silverlight and Blend 3 «  Adam Kinney

# Silverlight 3 - CollectionViewSource

Silverlight 3 - CollectionViewSource

Friday, November 27, 2009 11:52 PM by Name of the blog

# Silverlight 3 – CollectionViewSource | Mokosh

Pingback from  Silverlight 3 – CollectionViewSource | Mokosh

Wednesday, December 30, 2009 2:29 AM by Silverlight 3 – CollectionViewSource | Mokosh

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: