UIElement.ManipulationDelta Ereignis

Definition

Tritt ein, wenn sich die Position des Eingabegeräts während einer Bearbeitung ändert.

public:
 event EventHandler<System::Windows::Input::ManipulationDeltaEventArgs ^> ^ ManipulationDelta;
public event EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> ManipulationDelta;
member this.ManipulationDelta : EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> 
Public Custom Event ManipulationDelta As EventHandler(Of ManipulationDeltaEventArgs) 

Ereignistyp

EventHandler<ManipulationDeltaEventArgs>

Beispiele

Das folgende Beispiel zeigt einen Ereignishandler für das ManipulationDelta Ereignis. Im Beispiel wird die Eigenschaft verwendet, um die DeltaManipulation Größe zu verschieben, zu ändern und zu drehen.Rectangle Im Beispiel wird auch überprüft, ob das ManipulationDelta Ereignis während der Inertia aufgetreten ist und ob das Rechteck den Rand eines Fensters berührt. Wenn diese Fälle wahr sind, beendet die Anwendung die Manipulation, um zu verhindern, dass das Rechteck den sichtbaren Bereich der Anwendung verlässt. Dieses Beispiel ist Teil eines größeren Beispiels 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;
}
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

Hinweise

Das ManipulationDelta Ereignis tritt mehrmals auf, wenn der Benutzer fingerüber den Bildschirm während einer Manipulation und erneut zieht, wenn die Unkraft auftritt. Sie können die IsInertial Eigenschaft verwenden, um zu überprüfen, ob das Ereignis während der Inertia auftritt.

Das Element mit ManipulationDelta Ereignis tritt nicht auf, wenn das Ereignis auftritt. Sie müssen die Logik für das Element bereitstellen, das bearbeitet werden soll. DeltaManipulation Die CumulativeManipulation Eigenschaften, die vom Typ ManipulationDeltasind, enthalten Daten darüber, wie sich die Position der Manipulationen ändert und als verschieben, ändern oder drehen eines Objekts interpretiert wird. Sie wenden diese Informationen auf das Element an, das bearbeitet werden soll.

Weitere Informationen zu Manipulationen finden Sie in der Eingabeübersicht. Ein Beispiel für eine Anwendung, die auf Manipulationen reagiert, finden Sie unter Walkthrough: Creating Your First Touch Application.

Informationen zum Routingereignis

Bezeichnerfeld ManipulationDeltaEvent
Routingstrategie Bubbling
Delegat Eine EventHandler<TEventArgs> vom Typ ManipulationDeltaEventArgs.

Gilt für: