Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ManipulationDeltaEventArgs Class

Provides data for the ManipulationDelta event.

System.Object
  System.EventArgs
    System.Windows.RoutedEventArgs
      System.Windows.Input.InputEventArgs
        System.Windows.Input.ManipulationDeltaEventArgs

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)
public sealed class ManipulationDeltaEventArgs : InputEventArgs

The ManipulationDeltaEventArgs type exposes the following members.

  NameDescription
Public propertyCumulativeManipulationGets the cumulated changes of the current manipulation.
Public propertyDeltaManipulationGets the most recent changes of the current manipulation.
Public propertyDeviceGets the input device that initiated this event. (Inherited from InputEventArgs.)
Public propertyHandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. (Inherited from RoutedEventArgs.)
Public propertyIsInertialGets a value that indicates whether the ManipulationDelta event occurs during inertia.
Public propertyManipulationContainerGets the container that defines the coordinates for the manipulation.
Public propertyManipulationOriginGets the point from which the manipulation originated.
Public propertyManipulatorsGets a collection of objects that represents the touch contacts for the manipulation.
Public propertyOriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. (Inherited from RoutedEventArgs.)
Public propertyRoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. (Inherited from RoutedEventArgs.)
Public propertySourceGets or sets a reference to the object that raised the event. (Inherited from RoutedEventArgs.)
Public propertyTimestampGets the time when this event occurred. (Inherited from InputEventArgs.)
Public propertyVelocitiesGets the rates of the most recent changes to the manipulation.
Top
  NameDescription
Public methodCancelCancels the manipulation.
Public methodCompleteCompletes the manipulation without inertia.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodReportBoundaryFeedbackSpecifies that the manipulation has gone beyond certain boundaries.
Public methodStartInertiaStarts inertia on the manipulation by ignoring subsequent contact movements and raising the ManipulationInertiaStarting event.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The ManipulationDeltaEventArgs class contains data about changes in the position of a manipulation. The DeltaManipulation property contains the changes that occurred since the last ManipulationDelta event occurred. The CumulativeManipulation property contains the total changes that occurred for the current manipulation. You use one of those properties to transform the manipulated object.

You can end a manipulation by calling the Complete method or force the manipulation into inertia by calling the StartInertia method.

The following example shows an event handler for the ManipulationDelta event. The example uses the DeltaManipulation property to move, resize, and rotate a Rectangle. The example also checks whether the ManipulationDelta event occurred during inertia and whether the rectangle is touching the edge of a window. If those cases are true, the application stops the manipulation to prevent the rectangle from leaving the visible area of the application. 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;
}

.NET Framework

Supported in: 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.