The rendertransform attribute allows you to use a transform object to rotate, tilt, scale, and offset an element. There are several different transform objects:
- Rotatetransform: rotate the object at the specified angle.
- Skewtransform: skew the object.
- Scaletransform: scales up or down an object.
- Translatetransform: offset the object from the original coordinate.
In addition, there is a special type of transform object: transformgroup. You can use it to perform more operations on an object application.
The following is an example in the SDK,CodeAs follows:
< Canvas Width = "300" Height = "300"
Xmlns = "Http://schemas.microsoft.com/client/2007"
Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml"
>
< Rectangle Height = "100" Width = "100" Canvas. Left = "70" Canvas. Top = "10"
Fill = "Black" >
< Rectangle. rendertransform >
< Rotatetransform Angle = "45" />
</ Rectangle. rendertransform >
</ Rectangle >
< Rectangle Height = "100" Width = "100" Canvas. Left = "130" Canvas. Top = "10"
Fill = "Red" >
< Rectangle. rendertransform >
< Skewtransform Anglex = "30" />
</ Rectangle. rendertransform >
</ Rectangle >
< Rectangle Height = "100" Width = "100" Canvas. Left = "10" Canvas. Top = "190"
Fill = "Blue" >
< Rectangle. rendertransform >
< Scaletransform Scalex = "1.3" Scaley = ". 5" />
</ Rectangle. rendertransform >
</ Rectangle >
< Rectangle Height = "100" Width = "100" Canvas. Left = "160" Canvas. Top = "130"
Fill = "Green" >
< Rectangle. rendertransform >
< Transformgroup >
< Rotatetransform Angle = "45" />
< Scaletransform Scalex = ". 5" Scaley = "1.2" />
< Skewtransform Anglex = "30" />
</ Transformgroup >
</ Rectangle. rendertransform >
</ Rectangle >
</Canvas>
As shown in: This is directly set in XAML. In fact, you can also set it using JS functions. The following is a simple sample code:
VaRStransformg = '<transformgroup/> ';
VaROtransformg = ohost. createfromxaml (stransformg );
VaRStransformcollection = '<transformcollection/> ';
VaROtransformcollection = ohost. createfromxaml (stransformcollection );
VaRSrotatetransform = '<rotatetransform/> ';
VaROrotatetransform = ohost. createfromxaml (srotatetransform );
Orotatetransform. angle = 50;
Otransformcollection. Add (orotatetransform );
VaRSscaletransform = '<scaletransform/> ';
VaROscaletransform = ohost. createfromxaml (sscaletransform );
Oscaletransform. scalex = 5;
Oscaletransform. scaley = 5;
Otransformcollection. Add (oscaletransform );
otransformg. Children = otransformcollection;
oobject. rendertransform = otransformg;