This documentation is archived and is not being maintained.

Rect.Transform Method (Rect, Matrix)

Returns the rectangle that results from applying the specified matrix to the specified rectangle.

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

public static Rect Transform(
	Rect rect,
	Matrix matrix


Type: System.Windows.Rect
A rectangle that is the basis for the transformation.
Type: System.Windows.Media.Matrix
A matrix that specifies the transformation to apply.

Return Value

Type: System.Windows.Rect
The rectangle that results from the operation.

The following example shows how to use the Transform(Rect, Matrix) method to create a new Rect structure that results from applying a Matrix to an existing rectangle.

private Rect transformExample2()
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

    // Set the Size property of the rectangle with a width of 200
    // and a height of 60.
    myRectangle.Size = new Size(200, 60);

    // Creating a Matrix structure.
    Matrix myMatrix = new Matrix(0, 1, 1, 0, 20, 2);

    // The Transform method Transforms the specified rectangle using the specified matrix 
    // and returns the results.  
    // resultRect is an alterned version of myRectangle with a location of 20,2 rather
    // then 0,0 and a size of 60,200 rather then 200,60.
    Rect resultRect = Rect.Transform(myRectangle,myMatrix);

    return resultRect;


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.