ManipulationDelta.Scale 屬性

定義

取得或設定操作已依照乘數調整大小的量。

C#
public System.Windows.Vector Scale { get; }

屬性值

操作已調整大小的量。

範例

下列範例顯示 事件的事件處理程式 ManipulationDelta 。 這個範例會 Translation套用、 ScaleRotation 屬性來移動、重設大小及旋轉 Rectangle。 此範例是逐步解 說:建立您的第一個觸控應用程式中較大範例的一部分。

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

備註

ScaleExpansion 屬性都會報告重設大小操作。 這兩者之間的差異是報告值的方式。 屬性 Scale 會將值報告為乘數。 如果 Scale 為 0.5,則會將操作解譯為將大小減少 50%。 如果 Scale 為 2,則會將操作解譯為將大小增加 100%。 屬性 Expansion 會報告裝置獨立單位 (每單位 1/96 英吋) 重設大小操作。

適用於

產品 版本
.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, 10