Free 30 days to Launch!
(not a paid advertisement)
30 Day to Launch Phone
Rotating the triangle, how in the heck does that work? Simple. Really. Simple.
On the UserControl canvas, in this case triangle.xaml, you will see this XAML code:
<Canvas.RenderTransform> <RotateTransform x:Name="rotateTransform" Angle="0"/> </Canvas.RenderTransform>
Which could be rewritten (either way is valid):
The triangle that was discussed in the previous blog: “Silverlight Game: Talking about what we did simply – Path Data”, where the Path Data creates a triangle.
The UIElement .RenderTransform transforms the triangle presentation by getting and setting (in this case) the transform information that affects the rendering position of this triangle element.
The UIElement .RenderTransform uses a class named RotateTransform, which rotates an object clockwise about a specified point in a 2-D x-y coordinate system. Keep in mind that a UserControl is a small canvas, in this case the Width is 26 and Height is 40, so the triangle rotates around it’s origin and starts with a zero angle. Why did I write it this way? Not sure, I could have written it this way:
<RotateTransform x:Name="rotateTransform" CenterX="0" CenterY="0"/>
What did we learn in this blog:
In the next entry, we will utilize the RotateTransform in the “Code Behind”.