Hi guys,
I using Canvas UIelement to draw a rectangle with size (200,200). I want to move the rectangle to point (100,100), rotate with angle 45 degree and scale it with 50%.
I can not apply multi transform to Canvas' RenderTransform property one time. Please help me to do it soon...
Thanks, ![]()

How to apply multi Transforms to Canvas' RenderTransform property using code?
nolte
<TransformGroup>
<TranslateTransform .../>
<RotateTransform .../>
<ScaleTransform .../>
</TransformGroup>
</Rectangle.RenderTransform>
Moumen ITDev
Actually, I do not want to using XAML... I want to use C# code... Can you help me
DavidJW
-------------------------------------------------------------
Well... you might want to ask these types of questions in the Avalon forum.
However, if you want to convert XAML to C#, you look at it like an object model. So you'd get something like this:
// Assumes that you have a canvas variable called canvas.
canvas.Width = 200;
canvas.Height = 200;
canvas.Background = Brushes.AliceBlue; // just so it's easy to see
TransformGroup group = new TransformGroup();
group.Children.Add(new TranslateTransform(100, 100));
group.Children.Add(new ScaleTransform(0.5, 0.5));
group.Children.Add(new RotateTransform(45));
canvas.RenderTransform = group;
-David
----------------------------------------------------
Oh great! it works...
Thank David for your code.
Okan Oksak
Fernando Ronci
What's the syntax for setting a transform property after you assign the RenderTransform to your TransformGroup
I don't know the value at the time I create them -- so I can't pass it in like you did:
group.Children.Add(new TranslateTransform(100, 100));
I need to set it later on:
canvas.RenderTransform.[the syntax i need to access X] = 100;
Thanks in advance.
Nathan
----------
For anyone looking for this same thing, I got the answer here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1664521&SiteID=1