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