Export (0) Print
Expand All

MatrixTransform Class

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

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

public sealed class MatrixTransform : Transform
<MatrixTransform .../>
<object property="m11, m12, m21, m22, offsetX, offsetY"/>
- or -
<object property="Identity"/>

XAML Values

m11

The value at position (1, 1) of the transformation Matrix.

m12

The value at position (1, 2) of the transformation Matrix.

m21

The value at position (2, 1) of the transformation Matrix.

m22

The value at position (2, 2) of the transformation Matrix.

offsetX

The value at position (3, 1) of the transformation Matrix.

offsetY

The value at position (3, 2) of the transformation Matrix.

The MatrixTransform type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneMatrixTransformInitializes a new instance of the MatrixTransform class.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertySupported by Silverlight for Windows PhoneInverseGets the inverse of this transform, if it exists. (Inherited from Transform.)
Public propertySupported by Silverlight for Windows PhoneMatrixGets or sets the Matrix that defines this transformation.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetAnimationBaseValueReturns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneTransformTransforms the specified point and returns the result. (Inherited from GeneralTransform.)
Public methodSupported by Silverlight for Windows PhoneTransformBoundsTransforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from Transform.)
Public methodSupported by Silverlight for Windows PhoneTryTransformAttempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from Transform.)
Top

  NameDescription
Public fieldStatic memberSupported by Silverlight for Windows PhoneMatrixPropertyIdentifies the Matrix dependency property.
Top

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

A two-dimensional x-y plane uses a 3 x 3 matrix for transformations. You can multiply affine matrix transformations to form linear transformations, such as rotation and skew (shear) transformations 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 members in the last row, OffsetX and OffsetY, represent translation values.

Methods and properties usually specify the transformation matrix as a vector that has only six members; the members are as follows:

    (M11, M12, M21, M22, OffsetX, OffsetY)

You can offset the local (0,0) position for an object on a Canvas by using the Canvas.Left and Canvas.Top properties, but this does not operate as a transform; the object retains its own local (0,0) position in this case for transform purposes. For details on this concept, see Silverlight Layout System.

Multiple transforms can be applied with a TransformGroup.

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

Run this sample


<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>


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft