ManipulationDeltaEventArgs.IsInertial プロパティ

定義

慣性による処理中に ManipulationDelta イベントが発生するかどうかを示す値を取得します。Gets a value that indicates whether the ManipulationDelta event occurs during inertia.

public:
 property bool IsInertial { bool get(); };
public bool IsInertial { get; }
member this.IsInertial : bool
Public ReadOnly Property IsInertial As Boolean

プロパティ値

Boolean

慣性による処理中に ManipulationDelta イベントが発生する場合は true。ユーザーが UIElement に接触中にイベントが発生する場合は falsetrue if the ManipulationDelta event occurs during inertia; false if the event occurs while the user has contact with the UIElement.

次の例は、イベントのイベントハンドラーを示して ManipulationDelta います。The following example shows an event handler for the ManipulationDelta event. この例では、 ManipulationDelta 慣性中にイベントが発生したかどうかと、四角形がウィンドウの端に接しているかどうかを確認します。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.

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

注釈

このメソッドを使用して、 ManipulationDelta 慣性中にイベントを発生させるか、イベントを受け取る要素とユーザーが接続しているかを判断でき ManipulationDelta ます。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.

適用対象