July 2008
Intermediate to advanced
480 pages
11h 50m
English
While there is much that can be written about 2-D graphics, one of the more interesting (and at times confusing) aspects of taking control of graphics is transformations. Here, we'll look at an example of the art of transforming the up/down orientation of the page.
WPF makes simple transformations very simple, as shown in Example 3-9.
Example 3-9. A simple transformation
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Programming .NET 3.5 | Transformations: Rotate">
<Border Margin="30"
HorizontalAlignment="Left" VerticalAlignment="Top"
BorderBrush="Black" BorderThickness="1" >
<StackPanel Orientation="Vertical">
<Button Content="Top Button" Opacity="1" />
<Button Content="Middle Button" Opacity="1" />
<Button Content="Rotated Button">
<Button.RenderTransform>
<RotateTransform Angle="45" />
</Button.RenderTransform>
</Button>
</StackPanel>
</Border>
</Window>This example creates three buttons. The third button has a RenderTransform applied to it, and the RenderTransform has a child element, RotateTransform, whose attribute is an angle (in this case, 45 degrees). The button is rendered with a 45-degree clockwise rotation, as shown in Figure 3-15.

Figure 3-15. A 45-degree rotation
Read now
Unlock full access