Skip to main content
Home Forums Silverlight Design Designing with Silverlight How to assign two types of transforms in Canvas.RenderTransform
3 replies. Latest Post by leafinwind on August 28, 2008.
(0)
leafinwind
Member
5 points
10 Posts
08-28-2008 3:00 AM |
Hi,
I am planning to do both rotation and translation of the same user control. That user control contains a canvas. What I did is set one rotateTransform in Canvas.RenderTransform. It seems that I can only set one transform. I tried to put two there as is in the following code. But it can not compile.
What can I do if I still want to have control of two transformation types on this usercontrol object? Thanks.
<UserControl x:Class="Brick" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="60" Height="30"> <Canvas Height="30" Width="60" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,30,0,0"> <Canvas.RenderTransform> <RotateTransform x:Name="rotateTransform" Angle="0"/> <TranslateTransform x:Name="translateTransform" X="1" Y="1" /> </Canvas.RenderTransform> <Ellipse Height="30" Width="30" Canvas.Left="0" Canvas.Top="0" Fill="#FFD21B1B" Stroke="#FF000000"/> <Ellipse Height="30" Width="30" Canvas.Left="30" Canvas.Top="0" Fill="#FFF9E505" Stroke="#FF000000"/> </Canvas></UserControl>
Skyrunner
Contributor
2489 points
485 Posts
08-28-2008 4:37 AM |
You must use a <TransformGroup> markup inside RenderTransform.
HarshBar...
Star
9908 points
1,719 Posts
08-28-2008 5:02 AM |
If you will add Transform group like given below it will work...You can add like this it will work.
<UserControl x:Class="Brick" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="60" Height="30"> <Canvas Height="30" Width="60" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,30,0,0"> <Canvas.RenderTransform>
< TransformGroup> <RotateTransform x:Name="rotateTransform" Angle="0"/> <TranslateTransform x:Name="translateTransform" X="1" Y="1" />
<TransformGroup> </Canvas.RenderTransform> <Ellipse Height="30" Width="30" Canvas.Left="0" Canvas.Top="0" Fill="#FFD21B1B" Stroke="#FF000000"/> <Ellipse Height="30" Width="30" Canvas.Left="30" Canvas.Top="0" Fill="#FFF9E505" Stroke="#FF000000"/> </Canvas></UserControl>
08-28-2008 10:20 PM |
It works! Thank you guys.