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 is the following code, respectively, Translationbehavior, Expansionbehavior, rotationbehavior settings, so that its Possess inertial characteristics.
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=mti1ljy5lje0nc4zngi0otu2mzewmaj3d3cu Y25IBG9NCY5JB20CL2DUAWVSZWUVYXJJAGL2ZS8YMDEWLZA4LZE5L211BHRPLXRVDWNOLWL uzxj0aweuahrtba==&showad=0
SOURCE Download Address: Http://cid-c75f4e27adfe5bbc.office.live.com/self.aspx/GnieTech/WpfInertia.zip
Source: http://www.cnblogs.com/gnielee/