英語で読む

次の方法で共有


UIElement.ManipulationDelta イベント

定義

操作中に入力デバイスが位置を変更したときに発生します。

C#
public event EventHandler<System.Windows.Input.ManipulationDeltaEventArgs> ManipulationDelta;

イベントの種類

次の例は、 イベントのイベント ハンドラーを ManipulationDelta 示しています。 この例では、 プロパティを DeltaManipulation 使用して を移動、サイズ変更、回転します Rectangle。 この例では、慣性中にイベントが ManipulationDelta 発生したかどうか、および四角形がウィンドウの端に触れているかどうかも確認します。 これらのケースが true の場合、アプリケーションは操作を停止して、四角形がアプリケーションの可視領域から離れないようにします。 この例は、「 チュートリアル: 初めてのタッチ アプリケーションの作成」の大きな例の一部です。

C#
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;
}

注釈

イベントは ManipulationDelta 、操作中にユーザーが画面の上に指をドラッグし、慣性が発生したときに複数回発生します。 プロパティをIsInertial使用して、慣性中にイベントが発生しているかどうかをチェックできます。

イベントが発生した の 要素 ManipulationDelta は、イベントが発生しても影響を受けません。 操作する要素にロジックを指定する必要があります。 CumulativeManipulation型の プロパティと DeltaManipulation プロパティには、操作のManipulationDelta位置がどのように変化し、オブジェクトの移動、サイズ変更、または回転と解釈されるかに関するデータが含まれます。 その情報は、操作する要素に適用します。

操作の詳細については、「 入力の概要」を参照してください。 操作に応答するアプリケーションの例については、「 チュートリアル: 初めてのタッチ アプリケーションの作成」を参照してください。

ルーティングされたイベント情報

識別子フィールド ManipulationDeltaEvent
ルーティング戦略 バブル
代理人 EventHandler<TEventArgs> 型の ManipulationDeltaEventArgs

適用対象

製品 バージョン
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9