1.

Explain Rotate transform in WPF.

Answer»

Rotate transforms, as their name indicates, rotate an element around a specified angle. You can rotate a control, shape, or another element by certain degrees around a point by using the Rotate transform. In this WAY, you can create interesting user interfaces with both static and animated rotation. WPF provides a RotateTransform object that represents rotation. The Angle property indicates the degree of rotation in the clockwise direction. An element may also be rotated anticlockwise by setting a negative value. The X and Y coordinates of the center point are represented by the CenterX and CenterY PROPERTIES. By default, it uses the TOP leftmost corner of a given element as the center point and rotates it accordingly.  

Example: The FOLLOWING code creates two rectangles of equal size, but rotates the second rectangle by 45 degrees.

<Grid> <!-- Original Rectangle --> <Rectangle Width="200" Height="50" Fill="Yellow"/> <!-- Rectangle with 45 degrees rotation --> <Rectangle Width="200" Height="50" Fill="Blue" Opacity="0.5" Margin="61,27,117,184"> <Rectangle.RenderTransform> <RotateTransform CenterX="-50" CenterY="50" Angle="45" /> </Rectangle.RenderTransform> </Rectangle> </Grid>

As you can see in the following output, the second rectangle has been rotated by 45 degrees. 



Discussion

No Comment Found