Scales an object in the 2-D x-y coordinate system.
| XAML | <ScaleTransform .../> |
| Scripting | To create an object using scripting, see CreateFromXAML. |
Examples
The following XAML example uses a
ScaleTransform to scale text from its original size.
| XAML |
<TextBlock
FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text" />
<!-- Scale the text width using a ScaleTransform. -->
<TextBlock
Canvas.Top="40"
FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.0" />
</TextBlock.RenderTransform>
</TextBlock>
<!-- Scale the text height using a ScaleTransform. -->
<TextBlock
Canvas.Top="80"
FontFamily="Verdana"
FontSize="32"
FontWeight="Bold"
Foreground="SteelBlue"
Text="Scaled Text">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="1.0" ScaleY="1.5" />
</TextBlock.RenderTransform>
</TextBlock>
|
The example below shows how to increase the
ScaleX and
ScaleY property values
of a ScaleTransform applied to a
Rectangle every time that Rectangle is clicked.
| XAML |
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="200" Height="200">
<Rectangle MouseLeftButtonDown="handleMouseButtonDown"
Width="50" Height="50"
Fill="RoyalBlue">
<Rectangle.RenderTransform>
<!-- If you give the transform a name you can access it easily
from code. -->
<ScaleTransform x:Name="myScaleTransform" />
</Rectangle.RenderTransform>
</Rectangle>
</Canvas>
|
See Also
Transform Overview
Transform