WPF multi-touch development: Inertia)

Source: Internet
Author: User

From the previous example, we can find that if you move your finger away from the screen, the image will immediately stop. In this case, WPF provides another inertial effect (inertia ). It can make the UI unit move more in line with physical characteristics, more practical and smooth.

In frontCodeAdd the manipulationinertiastarting event for <canvas>.

    canvas   x  :   name   =" touchpad "  background   =" gray "  manipulationstarting   =" image_manipulationstarting "  manipulationdelta   =" image_manipulationdelta "  manipulationcompleted   =" image_manipulationcompleted "  manipulationinertiastarting   =" image_manipulationinertiastarting ">  

The content of the image_manipulationinertiastarting event is as follows: You can set translationbehavior, expansionbehavior, and rotationbehavior to enable inertia.

 Private void Image_manipulationinertiastarting ( Object Sender, Manipulationinertiastartingeventargs E) {e. translationbehavior = New  Inertiatranslationbehavior (); E. translationbehavior. initialvelocity = E. initialvelocities. linearvelocity; E. translationbehavior. desireddeceleration = 10.0*96.0/(1000.0*1000.0); E. expansionbehavior = New  Inertiaexpansionbehavior (); E. expansionbehavior. initialvelocity = E. initialvelocities. expansionvelocity; E. expansionbehavior. desireddeceleration = 0.1*96/1000 .0*1000.0; E. rotationbehavior = New  Inertiarotationbehavior (); E. rotationbehavior. initialvelocity = E. initialvelocities. angularvelocity; E. rotationbehavior. desireddeceleration = 720/(1000.0*1000.0 );}
Program Demo

The following video shows that all images have inertial effects during manipulation.

 

Related Article

1. WPF multi-touch development: Install multi-point touch screen simulator on Windows 7

2. WPF multi-touch development: Raw touch)

3. WPF multi-touch development: Manipulation)

 

Source code download

Wpfinertia.zip

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.