Rect.Transform Method (Rect, Matrix)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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
Available since 3.0
Return to top