Matrix structure
Represents a 3 × 3 affine transformation matrix used for transformations in twodimensional space.
Syntax
<Matrix .../>
<object property="m11,m12,m21,m22,offsetX,offsetY"/>  or  <object property="m11 m12 m21 m22 offsetX offsetY"/> or <object property="Identity"/>
XAML Values
 m11

The numeric value in the first row and first column of this Matrix.
 m12

The numeric value in the first row and second column.
 m21

The numeric value in the second row and first column.
 m22

The numeric value in the second row and second column.
 offsetX

The numeric value in the third row and first column.
 offsetY

The numeric value in the third row and second column.
 Identity

The literal Identity value.
Attributes
 [Version(0x06020000)]
 [WebHostHidden()]
Members
The Matrix structure has these types of members:
Constructors
The Matrix structure has these constructors.
Constructor  Description 

Matrix  Initializes a Matrix structure. 
Fields
The Matrix structure has these fields.
Field  Data type  Description 

M11 
System.Double [.NET]  float64 [C++] 
The value of the first row and first column of this Matrix structure. 
M12 
System.Double [.NET]  float64 [C++] 
The value of the first row and second column of this Matrix structure. 
M21 
System.Double [.NET]  float64 [C++] 
The value of the second row and first column of this Matrix structure. 
M22 
System.Double [.NET]  float64 [C++] 
The value of the second row and second column of this Matrix structure. 
OffsetX 
System.Double [.NET]  float64 [C++] 
Gets or sets the value of the third row and first column of this Matrix structure. 
OffsetY 
System.Double [.NET]  float64 [C++] 
Gets or sets the value of the third row and second column of this Matrix structure. 
Methods
The Matrix structure has these methods. It also inherits methods from the Object class.
Method  Description 

Equals(Matrix) [C#, VB]  Compares two Matrix structures for equality. 
Equals(Object) [C#, VB]  Determines whether the specified object is equal to a Matrix. 
GetHashCode [C#, VB]  Gets a hash code for this object. 
ToString [C#, VB]  Converts a Matrix to a String representation. 
ToString(IFormatProvider) [C#, VB]  Creates a String representation of this Matrix. 
Transform  Transforms the specified point by the Matrix and returns the result. 
Operators
The Matrix structure has these operators.
Operator  Description 

Equality  Compares two Matrix structures for equality. 
Inequality  Compares two Matrix structures for inequality. 
Properties
The Matrix structure has these properties.
Property  Access type  Description 

Readonly  Gets an identity Matrix.  
Readonly  Gets a value that indicates whether this Matrix structure is an identity matrix.  
Read/write  Gets or sets the value of the first row and first column of this Matrix structure.  
Read/write  Gets or sets the value of the first row and second column of this Matrix structure.  
Read/write  Gets or sets the value of the second row and first column of this Matrix structure.  
Read/write  Gets or sets the value of the second row and second column of this Matrix structure.  
Read/write  Gets or sets the value of the third row and first column of this Matrix structure.  
Read/write  Gets or sets the value of the third row and second column of this Matrix structure. 
Remarks
A 3×3 matrix is used for transformations in a twodimensional xy plane. Affine transformation matrices can be multiplied to form any number of linear transformations, such as rotation and skew (shear), followed by translation. An affine transformation matrix has its final column equal to (0, 0, 1), so only the members in the first two columns need to be specified. Note that vectors are expressed as rowvectors, not column vectors.
A Matrix is stored using rowmajor order and has the following structure:
M11  M12  0 
M21  M22  0 
OffsetX  OffsetY  1 
The members in the last row, OffsetX and OffsetY, represent translation values.
In methods and properties, the transformation matrix is usually specified as a vector with only six members, as follows: (M11, M12, M21, M22, OffsetX, OffsetY)
Although you can use a Matrix structure directly to translate individual points, or with a MatrixTransform to transform objects, the Windows Runtime also provides a set of classes that can transform objects without working directly with matrices:
Properties of a Matrix can be animated (as one or more DoubleAnimation animations or DoubleAnimationUsingKeyFrames).
Matrix is the property value for the MatrixTransform.Matrix property. Related types can be used for transformation matrices in threedimensional space and then used for a projection. See Matrix3D and Matrix3DProjection.
Language projections and members of Matrix
If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or in Visual C++ component extensions (C++/CX) then Matrix has nondata members available, and its data members are exposed as readwrite properties, not fields.
If you are programming with C++ using the Windows Runtime Template Library (WRL), then only the data member fields exist as members of Matrix, and you cannot use the utility methods or properties listed in the members table. WRL code can access similar utility methods that exist on the MatrixHelper class.
Examples
This example XAML defines a Matrix that provides data for a MatrixTransform applied to a rectangular shape. In this case, the matrix combines an offset (OffsetX and OffsetY) and a skew (M12). Note that this same effect could have been produced by combining a TranslateTransform and a SkewTransform. Whether to use a single Matrix or combinations of discrete transforms is a matter of coding style; the results are identical.
<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>
Requirements (device family)
Device family 


API contract 

Namespace 

Metadata 

Requirements (operating system)
Minimum supported client  Windows 8 

Minimum supported server  Windows Server 2012 
Minimum supported phone  Windows Phone 8.1 [Windows Runtime apps only] 
Namespace 

Metadata 
