Transformation C# Help

Because WPF is based on DirectX,which is vector-based, you can resize every element, The vector-based graphics are now scaled, rotated, and skewed. Hit testing (for example with mouse moves and mouse clicks) is still working without the need for manual position calculation.

Adding the ScaleTransform element to the LayoutTransform property of the Canvas element, as shown, resizes the content of the complete canvas by 2 in X and Y direction.

<ScaleTran.form Scale X 2″ Scale Y “2” I>
</Canvas. LayoutTransform>

Rotation can be done in a similar way as scaling, Using the RotateTranform element you can define the Angle for the rotation.

<Canvas. LayoutTransform>
<Rotate.Transform Angle”40″ I>
</Canvas. LayoutTransform>

For skewing, you Can use the SkewTranform element, With skewing you can assign angels for the X and the Y direction.

<SkewTransform Angle X.’20” Angle Y.’25’ I>
</Canvas . LayoutTransform>

Figure 34-8 shows the result of all the transformations.

The figure placed inside a stack panel, starting from the left side, the first figure is resized, the second figure rotated, and the third figure skewed, To more easily see the difference, the background property of the canvas element are set to different colors.

Figure 34-8

Figure 34-8

Posted on November 3, 2015 in Windows Presentation Foundation

Share the Story

Back to Top