MatrixTransform Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Creates an arbitrary affine matrix transformation that is used to manipulate objects or coordinate systems in a two-dimensional plane.
System.Windows::DependencyObject
System.Windows.Media::GeneralTransform
System.Windows.Media::Transform
System.Windows.Media::MatrixTransform
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
The MatrixTransform type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Dispatcher | Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.) |
![]() | Inverse | Gets the inverse of this transform, if it exists. (Inherited from Transform.) |
![]() | Matrix | Gets or sets the Matrix that defines this transformation. |
| Name | Description | |
|---|---|---|
![]() | CheckAccess | Determines whether the calling thread has access to this object. (Inherited from DependencyObject.) |
![]() | ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject.) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetAnimationBaseValue | Returns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetValue | Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.) |
![]() | SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | Transform | Transforms the specified point and returns the result. (Inherited from GeneralTransform.) |
![]() | TransformBounds | Transforms the specified bounding box and returns an axis-aligned bounding box that is exactly large enough to contain it. (Inherited from Transform.) |
![]() | TryTransform | Attempts to transform the specified point and returns a value that indicates whether the transformation was successful. (Inherited from Transform.) |
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 Layout and panels for Windows Phone.
Multiple transforms can be applied with a TransformGroup.
The following example transforms the position and skew of a rectangle using a MatrixTransform.
<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>




