How to apply multi Transforms to Canvas.RenderTransform?
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,
[385 byte] By [
hoangha] at [2008-2-12]
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