Export (0) Print
Expand All

ManipulationDelta Class

Contains transformation data that is accumulated when manipulation events occur.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public class ManipulationDelta

The ManipulationDelta class contains information about the changes in the position of a manipulation. Windows Presentation Foundation (WPF) interprets the changes as a Translation, Expansion, or Rotation. When the ManipulationDelta event occurs on a UIElement, use the properties on a ManipulationDelta object to transform the object that should be manipulated. The ManipulationDeltaEventArgs class provides two properties of type ManipulationDelta: DeltaManipulation and CumulativeManipulation.

For more information about manipulations, see the Input Overview. For an example of an application that responds to manipulations, see Walkthrough: Creating Your First Touch Application.

The following example shows an event handler for the ManipulationDelta event. The example applies the Translation, Scale, and Rotation properties to move, resize, and rotate a Rectangle. This example is part of a larger example in Walkthrough: Creating Your First Touch Application.


void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{

    // Get the Rectangle and its RenderTransform matrix.
    Rectangle rectToMove = e.OriginalSource as Rectangle;
    Matrix rectsMatrix = ((MatrixTransform)rectToMove.RenderTransform).Matrix;

    // Rotate the Rectangle.
    rectsMatrix.RotateAt(e.DeltaManipulation.Rotation, 
                         e.ManipulationOrigin.X, 
                         e.ManipulationOrigin.Y);

    // Resize the Rectangle.  Keep it square 
    // so use only the X value of Scale.
    rectsMatrix.ScaleAt(e.DeltaManipulation.Scale.X, 
                        e.DeltaManipulation.Scale.X, 
                        e.ManipulationOrigin.X,
                        e.ManipulationOrigin.Y);

    // Move the Rectangle.
    rectsMatrix.Translate(e.DeltaManipulation.Translation.X,
                          e.DeltaManipulation.Translation.Y);

    // Apply the changes to the Rectangle.
    rectToMove.RenderTransform = new MatrixTransform(rectsMatrix);

    Rect containingRect =
        new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);

    Rect shapeBounds =
        rectToMove.RenderTransform.TransformBounds(
            new Rect(rectToMove.RenderSize));

    // Check if the rectangle is completely in the window.
    // If it is not and intertia is occuring, stop the manipulation.
    if (e.IsInertial && !containingRect.Contains(shapeBounds))
    {
        e.Complete();
    }


    e.Handled = true;
}


System.Object
  System.Windows.Input.ManipulationDelta

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Community Additions

Show:
© 2014 Microsoft