#767 – Transform Basics

In WPF, you can easily apply one or more 2D transforms to user interface elements.  A transform is a mathematical function applied to a user interface element that does one or more of the following:

  • Scales the element – make it bigger or smaller
  • Rotates the element – spin the element around some point
  • Translates the element – move the element up/down/left/right
  • Skews the element – tilt the element, e.g. turn a rectangular element into a rhomboid

In the example below, the second label has a rotation transform applied to it, which rotates it by 15 degrees (clockwise).

    <StackPanel Orientation="Horizontal">
        <Label Content="Grand Canyon" Background="LightPink"
               VerticalAlignment="Center" Margin="5"/>
        <Label Content="Grand Tetons" Background="Bisque"
               VerticalAlignment="Center" Margin="5" >
            <Label.RenderTransform>
                <RotateTransform Angle="15"/>
            </Label.RenderTransform>
        </Label>
    </StackPanel>

764-001

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

3 Responses to #767 – Transform Basics

  1. Alian says:

    Hey man, just to leave you a post for contratulation, sorry for my English, I’m spanish speaker. WPF is one of my interests, I aprecciate to much your post, thanks.

  2. Pingback: Dew Drop – March 1, 2013 (#1,507) | Alvin Ashcraft's Morning Dew

Leave a comment