ManipulationDeltaEventArgs.ReportBoundaryFeedback Method (ManipulationDelta)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Specifies that the manipulation has gone beyond certain boundaries.

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

public void ReportBoundaryFeedback(
	ManipulationDelta unusedManipulation


Type: System.Windows.Input.ManipulationDelta

The portion of the manipulation that represents moving beyond the boundary.

Exception Condition

unusedManipulation is null.

Use the ReportBoundaryFeedback method to indicate that an element has moved beyond a certain boundary. For example, if a user moves an element outside of the bounds of a Window, you can call this method to report that to the window. When you call ReportBoundaryFeedback, the ManipulationBoundaryFeedback event occurs. By default, the Window subscribes to the ManipulationBoundaryFeedback event to provide visual feedback to the user that a boundary has been reached. You can subscribe to ManipulationBoundaryFeedback to implement custom behavior.

The following example shows an event handler for the ManipulationDelta event that calls the ReportBoundaryFeedback method when the user moves the element over the edge of its container. To test this example, follow the steps in Walkthrough: Creating Your First Touch Application and replace the code in step 5 with this code.

void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)

    Rectangle rectToMove = e.OriginalSource as Rectangle;
    Vector overshoot;

    // When the element crosses the boundary of the window, check whether 
    // the manipulation is in inertia.  If it is, complete the manipulation.
    // Otherwise, report the boundary feedback.
    if (CalculateOvershoot(rectToMove, e.ManipulationContainer, out overshoot))
        if (e.IsInertial)
            e.Handled = true;
            //Report that the element hit the boundary
            e.ReportBoundaryFeedback(new ManipulationDelta(overshoot, 0, new Vector(), new Vector()));


    // Move the element as usual.

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

    // Rotate the Rectangle.

    // Resize the Rectangle.  Keep it square 
    // so use only the X value of Scale.

    // Move the Rectangle.

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

    e.Handled = true;

private bool CalculateOvershoot(UIElement element, IInputElement container, out Vector overshoot)
    // Get axis aligned element bounds
    var elementBounds = element.RenderTransform.TransformBounds(

    //double extraX = 0.0, extraY = 0.0;
    overshoot = new Vector();

    FrameworkElement parent = container as FrameworkElement;
    if (parent == null)
        return false;

    // Calculate overshoot.  
    if (elementBounds.Left < 0)
        overshoot.X = elementBounds.Left;
    else if (elementBounds.Right > parent.ActualWidth)
        overshoot.X = elementBounds.Right - parent.ActualWidth;

    if (elementBounds.Top < 0)
        overshoot.Y = elementBounds.Top;
    else if (elementBounds.Bottom > parent.ActualHeight)
        overshoot.Y = elementBounds.Bottom - parent.ActualHeight;

    // Return false if Overshoot is empty; otherwsie, return true.
    return !Vector.Equals(overshoot, new Vector());

.NET Framework
Available since 4.0
Return to top