TransformContentToViewport(Rect, Matrix) Method

Definition

Assembly PanAndZoom.dll

Transforms content bounds to viewport coordinates, accounting for layout offset.

public static Rect TransformContentToViewport(Rect elementBounds, Matrix matrix)

Parameters

elementBounds
Avalonia.Rect

The element bounds (includes Position where Avalonia laid out the element).

matrix
Avalonia.Matrix

The transform matrix.

Returns

Avalonia.Rect
The actual visual bounds in viewport coordinates.

Remarks

When a child element has a differnt size than the ZoomBorder, Avalonia's layout system positions it (e.g., centered) resulting in a non-zero Position in elementBounds. This layout offset is in viewport coordinates and should not be scaled by the transform matrix. This method correctly separates the two coordinate systems.