MatrixTransform Object

Creates an arbitrary affine matrix transformation that is used to manipulate objects or coordinate systems in a 2-D plane.

XAML
<MatrixTransform .../>
Scripting
To create an object using scripting, see CreateFromXAML.

Properties

Matrix, Name

Methods

Equals, FindName, GetHost, GetValue, SetValue

Remarks

Use the MatrixTransform class to create custom transformations that are not provided by the RotateTransform, ScaleTransform, SkewTransform, and TranslateTransform classes.

A 3x3 matrix is used for transformations in a 2-D x-y plane. You can multiply affine matrix transformations to form linear transformations, such as rotation and skew (shear) that are followed by translation.

An affine matrix transformation has its final column equal to (0, 0, 1); therefore, you only have to specify the members in the first two columns.

The local 0,0 for an object can be offset on a Canvas using Canvas.Left and Canvas.Top, but this does not operate as a transform; the object retains its own local 0,0 in this case for transform purposes. For details on this concept, see Object Layout in Silverlight.

Multiple transforms can be applied with a TransformGroup.

Examples

The following example transforms the position and skew of a rectangle using a MatrixTransform.

XAML
<Canvas
  xmlns="https://schemas.microsoft.com/client/2007"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  Width="400" Height="300">
  <Rectangle Width="60" Height="60" Fill="Blue">
    <Rectangle.RenderTransform>
      <MatrixTransform>
        <MatrixTransform.Matrix >
          <!-- This matrix transforms the x,y position of
               the rectangle and skews it. -->
          <Matrix OffsetX="30" OffsetY="100" M12="0.5" />
        </MatrixTransform.Matrix>
      </MatrixTransform>
    </Rectangle.RenderTransform>
  </Rectangle>
</Canvas>

See Also

Transform Overview
Transform