Windows Phone 7 touch screen event manipulation)

Source: Internet
Author: User

Windows Phone 7 provides Silverlight and xNa with a very sensitive and touchable screen. It is not like some touch screens that simulate the mouse or recognize handwriting.

At least four fingers can be detected on the Windows Phone 7 multi-touch screen and operated together to make full use of the touch screen.

In Silverlight development, events are used to detect touch-screen events, including low-level and high-level interfaces. The lower level is mainly the framereported event. The higher level is the event defined in the uielement class, including manipulationstarted, manipulationdelta, and manipulationcompleted. These three events work together to complete touch operations, they can be used in any subclass of uielement.

Today we will talk about the manipulation event.

I. Event Description

1. manipulationstarted event

Occurs when the finger presses the touch screen

2. manipulationdelta

Occurs when the finger moves on the touch screen.

3. manipulationcompleted

Occurs when the touch screen is released by the finger

II. Specific Application

1. Create a project

2. Add an image for demonstration.

3. Modify mainpage. XAML

< Grid X: Name = "Layoutroot" Background = "Transparent" >
< Grid. rowdefinitions >
< Rowdefinition Height = "Auto" / >
< Rowdefinition Height = "*" / >
< Rowdefinition Height = "*" / >
< /Grid. rowdefinitions >

< Textblock X: Name = "Title" Fontsize = "40" TEXT = "Multi-touch" Textalignment = "Center" / >
< Canvas X: Name = "Contentcanvas" Grid. Row = "1" >
< Image Source = "1.jpg"  
X: Name = "Image1" Stretch = "Fill" Width = "500" Manipulationdelta = "Imageappsmanipulationdelta" Manipulationstarted = "Imageappsmanipulationstarted" Manipulationcompleted = "Imageappsmanipulationcompleted" >
< /Image >
< /Canvas >
< Textblock X: Name = "Info" Fontsize = "25" Grid. Row = "2" Textwrapping = "Wrap" Width = "500" Minheight = "40" TEXT = "Screen information" Textalignment = "Center" Verticalalignment = "Bottom" / >
< /Grid >

 

Image for demonstration

Textblock is used to display coordinate information of moving fingers.

4. Modify mainpage. CS

Public Partial Class Mainpage: phoneapplicationpage
{
Private Compositetransform;

// constructor
Public mainpage ()
{< br> initializecomponent ();
supportedorientations = supportedpageorientation. portrait | supportedpageorientation. landscape;


// manipulationdelta + = imagedeskmanipulationdelta;
compositetransform = New compositetransform ();
image1.rendertransform = compositetransform;
}

private void imageworkflow manipulationdelta (Object sender, manipulationdeltaeventargs E)
{< br> If (E. deltamanipulation. scale. x! = 0)
compositetransform. scalex * = E. deltamanipulation. Scale. X;
If (E. deltamanipulation. Scale. y! = 0)
compositetransform. scaley * = E. deltamanipulation. Scale. Y;

compositetransform. translatex + = E. deltamanipulation. translation. x;
compositetransform. translatey + = E. deltamanipulation. translation. y;
This . info. TEXT = "moving images" + "\ n" + "X: " + E. manipulationorigin. x. tostring () + " + " Y: " + E. manipulationorigin. y. tostring ();
}

private void imageworkflow manipulationstarted ( Object sender, manipulationstartedeventargs E)
{< br> This . info. TEXT = "starting to move an image" + "\ n" + "X: " + E. manipulationorigin. x. tostring () + " + " Y: " + E. manipulationorigin. y. tostring ();
}

private void imageworkflow manipulationcompleted ( Object sender, manipulationcompletedeventargs E)
{< br> This . info. TEXT = "Stop moving an image" + "\ n" + "X: " + E. manipulationorigin. x. tostring () + " + " Y: " + E. manipulationorigin. y. tostring ();
}< BR >}this article from the eternal memory blog, original address: http://www.cnblogs.com/salam/archive/2010/12/22/1914167.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.