UIElement.ManipulationDelta Událost

Definice

Nastane, když vstupní zařízení změní pozici během manipulace.

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) 

Event Type

Příklady

Následující příklad ukazuje obslužnou rutinu ManipulationDelta události pro událost. Příklad používá DeltaManipulation vlastnost k přesunutí, změně velikosti a otočení objektu Rectangle. Příklad také zkontroluje, jestli ManipulationDelta došlo k události během nečinnosti a zda se obdélník dotýká okraje okna. Pokud jsou tyto případy pravdivé, aplikace zastaví manipulaci, aby zabránila obdélníku opustit viditelnou oblast aplikace. Tento příklad je součástí většího příkladu v návodu: Vytvoření první dotykové aplikace.

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

Poznámky

K ManipulationDelta události dochází několikrát, když uživatel během manipulace přetáhne prsty na obrazovku a znovu při výskytu nečinnosti. Pomocí vlastnosti můžete IsInertial zkontrolovat, jestli k události dochází během nečinnosti.

Prvek s událostí ManipulationDelta není ovlivněn žádným způsobem, když dojde k události. Logiku musíte poskytnout elementu, který má být manipulován. DeltaManipulation VlastnostiCumulativeManipulation, které jsou typu ManipulationDelta, obsahují data o tom, jak se mění pozice manipulace a interpretuje jako pohybující se, změna velikosti nebo otočení objektu. Tuto informaci použijete u elementu, který má být manipulován.

Další informace o manipulaci najdete v přehledu vstupu. Příklad aplikace, která reaguje na manipulaci, najdete v části Návod: Vytvoření první dotykové aplikace.

Informace o směrované události

Položka Hodnota
Pole Identifikátor ManipulationDeltaEvent
Strategie směrování Bublající
Delegát EventHandler<TEventArgs> typu ManipulationDeltaEventArgs.

Platí pro