<!-- Scales a rectangle by 200% from a center of (0,0).-->
<Rectangle Height="50" Width="50" Fill="#CCCCCCFF"
Stroke="Blue" StrokeThickness="2"
Canvas.Left="100" Canvas.Top="100">
<Rectangle.RenderTransform>
<ScaleTransform CenterX="0" CenterY="0" ScaleX="2" ScaleY="2" />
</Rectangle.RenderTransform>
</Rectangle>
Typically, you set CenterX and CenterY to the center of the object that is scaled: (Width/2, Height/2).
The following example shows another Rectangle that is doubled in size; however, this ScaleTransform has a value of 25 for both CenterX and CenterY, which corresponds to the center of the rectangle.
<!-- Scales a rectangle by 200% from a center of (25,25).-->
<Rectangle Height="50" Width="50" Fill="#CCCCCCFF"
Canvas.Left="100" Canvas.Top="100" Stroke="Blue" StrokeThickness="2">
<Rectangle.RenderTransform>
<ScaleTransform CenterX="25" CenterY="25" ScaleX="2" ScaleY="2" />
</Rectangle.RenderTransform>
</Rectangle>
The following illustration shows the difference between the two ScaleTransform operations. The dotted line shows the size and position of the rectangle before scaling.
Two ScaleTransform operations with identical ScaleX and ScaleY values but different centers
.gif)
For the complete sample, see 2-D Transforms Sample.