ManipulationDeltaEventArgs.IsInertial Property

 
System_CAPS_noteNote

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

Gets a value that indicates whether the ManipulationDelta event occurs during inertia.

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

Public Property IsInertial As Boolean
	Get
	Private Set
End Property

Property Value

Type: System.Boolean

true if the ManipulationDelta event occurs during inertia; false if the event occurs while the user has contact with the UIElement.

You can use this method to determine whether the ManipulationDelta event occurs during inertia or while the user has contact with the element that receives the ManipulationDelta event.

The following example shows an event handler for the ManipulationDelta event. The example 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.

Private Sub Window_ManipulationDelta(ByVal sender As Object, ByVal e As ManipulationDeltaEventArgs)

    ' Get the Rectangle and its RenderTransform matrix.
    Dim rectToMove As Rectangle = e.OriginalSource
    Dim rectTransform As MatrixTransform = rectToMove.RenderTransform
    Dim rectsMatrix As Matrix = rectTransform.Matrix


    ' Rotate the shape
    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 center
    rectsMatrix.Translate(e.DeltaManipulation.Translation.X,
                          e.DeltaManipulation.Translation.Y)

    ' Apply the changes to the Rectangle.
    rectTransform = New MatrixTransform(rectsMatrix)
    rectToMove.RenderTransform = rectTransform

    Dim container As FrameworkElement = e.ManipulationContainer
    Dim containingRect As New Rect(container.RenderSize)

    Dim shapeBounds As Rect = rectTransform.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 AndAlso Not containingRect.Contains(shapeBounds) Then
        e.Complete()
    End If

    e.Handled = True
End Sub

.NET Framework
Available since 4.0
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: