Chapter 20. Transformations and Effects

As is mentioned in Chapter 1, WPF uses DirectX as its rendering engine. DirectX provides access to any high-performance graphics hardware available on the system, so it can produce amazing effects relatively quickly and easily.

This chapter looks at two useful techniques that WPF gets as a benefit of using DirectX: transformations and bitmap effects. Judicial use of these can make an application easier to use and more attractive.

Transformations

A transformation alters an object's geometry before it is drawn. Different kinds of transformations stretch, rotate, squash, skew, and move an object.

Internally WPF represents transformations using 3-by-3 matrices and manipulates them with linear algebra. Fortunately, you don't need to understand how transformations work to use them in your XAML code.

WPF provides four basic kinds of transformations represented by the following XAML elements:

  • RotateTransform — This transformation rotates an object. The Angle property determines the number of degrees by which the object is rotated clockwise.

  • ScaleTransform — This transformation scales the object vertically and horizontally. The ScaleX and ScaleY properties determine the horizontal and vertical scale factors respectively.

  • SkewTransform — This transformation skews the object by rotating its X and Y axes through an angle given by the AngleX and AngleY properties.

  • TranslateTransform — This transformation moves the object. The X and Y properties determine how far ...

Get WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.