UIElement.ManipulationDelta Gebeurtenis
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Treedt op wanneer het invoerapparaat de positie wijzigt tijdens een manipulatie.
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)
Gebeurtenistype
Voorbeelden
In het volgende voorbeeld ziet u een gebeurtenis-handler voor de ManipulationDelta gebeurtenis. In het voorbeeld wordt de DeltaManipulation eigenschap gebruikt om een Rectangle. In het voorbeeld wordt ook gecontroleerd of de ManipulationDelta gebeurtenis heeft plaatsgevonden tijdens de traagheid en of de rechthoek de rand van een venster raakt. Als deze gevallen waar zijn, stopt de toepassing de manipulatie om te voorkomen dat de rechthoek het zichtbare gebied van de toepassing verlaat. Dit voorbeeld maakt deel uit van een groter voorbeeld in Walkthrough: Your First Touch Application maken.
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
Opmerkingen
De ManipulationDelta gebeurtenis treedt meerdere keren op wanneer de gebruiker vingers over het scherm sleept tijdens een manipulatie en opnieuw wanneer er traagheid optreedt. U kunt de IsInertial eigenschap gebruiken om te controleren of de gebeurtenis plaatsvindt tijdens traagheid.
Het element waarop de ManipulationDelta gebeurtenis zich voordoet, wordt op geen enkele manier beïnvloed wanneer de gebeurtenis plaatsvindt. U moet de logica opgeven voor het element dat moet worden gemanipuleerd. De CumulativeManipulation eigenschappen, DeltaManipulation die van het type ManipulationDeltazijn, bevatten gegevens over hoe de positie van de manipulaties wordt gewijzigd en geïnterpreteerd als verplaatsen, vergroten of draaien van een object. U past die informatie toe op het element dat moet worden gemanipuleerd.
Zie het invoeroverzicht voor meer informatie over manipulaties. Zie Walkthrough: Your First Touch Application maken voor een voorbeeld van een toepassing die reageert op manipulaties.
Gerouteerde gebeurtenisgegevens
| Item | Waarde |
|---|---|
| Id-veld | ManipulationDeltaEvent |
| Routeringsstrategie | Borrelen |
| Gedelegeerde | EventHandler<TEventArgs> van het type ManipulationDeltaEventArgs. |