From the previous example, you can see that if you move your finger away from the screen while the picture is moving, the picture stops immediately, in which case WPF provides another inertia effect (inertia). It allows the UI unit to move more physically, more realistically, and more smoothly.
On the basis of the preceding code, additional manipulationinertiastarting events need to be added for <Canvas>.
<canvas x:name= "TouchPad" background= "Gray"
Manipulationstarting= "Image_manipulationstarting"
Manipulationdelta= "Image_manipulationdelta"
Manipulationcompleted= "Image_manipulationcompleted"
manipulationinertiastarting= "Image_manipulationinertiastarting" >
Image_manipulationinertiastarting event content as follows code, respectively, Translationbehavior, Expansionbehavior, rotationbehavior settings, Make it have the inertia characteristic.
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 can be seen in the manipulation, the picture has an inertial effect.
Video Address: http://static.youku.com/v1.0.0122/v/swf/qplayer.swf?VideoIDS=XMTk4MjUyNDAw&embedid= Mti1ljy5lje0nc4zngi0otu2mzewmaj3d3cuy25ibg9ncy5jb20cl2duawvszwuvyxjjagl2zs8ymdewlza4lze5l211bhrplxrvdwnolwluzxj0aweuahrtb A==&showad=0
SOURCE Download Address: http://public.blu.livefilestore.com/y1pA8pt32bGc_1znfRppqLoDSS7hKRAougUyNOv2NOkG_ N-ea4vzyytwkokn5xc7e3abor2yywwr1cbutogq3mpgg/wpfinertia.zip?download&psid=1