New to Telerik UI for WinForms? Download free 30-day trial

Element Offset Calculations

Location Offset Factors

The factors that produce the location offset of an element relative to its parent are:

  1. Location of the rectangle fed to the child Arrange method.

  2. Parent border thickness.

  3. Parent padding.

  4. Child margin.

  5. Child location.

  6. Child alignment.

  7. Child PositionOffset.

There are multiple properties storing offsets and bounds of an element. The sum of items 1 through 6 produces the LayoutOffset. The sum of items 1 through 7 inclusive produces the offset as stored in the RadElement TransformationMatrix.

LayoutOffset

The RadElement LayoutOffset is the sum of the arrange rectangle offset, parent border, padding, child margin, child location and alignment. In the figure below the "Final Rect Offset" illustrates the offset of the arrange rectangle where parent content is rendered. "Layout offset" indicates the offset represented by the LayoutOffset property.

tpf-layout-element-offset-calculations 001

PositionOffset

The offset of the origin of the coordinate system used when painting an element and its children. The PositionOffset is relative to the parent of an element. Setting PositionOffset has no influence on other layout properties and is only used to paint the element using an offset. The area of the element appearing outside of the parent bounds is clipped.

The example below shows a FillPrimitive where the PositionOffset if 5 pixels down and 5 pixels in.

tpf-layout-element-offset-calculations 002

Setting PositionOffset

BorderPrimitive rectanglePrimitive = new BorderPrimitive();
rectanglePrimitive.ForeColor = Color.Red;
rectanglePrimitive.MinSize = new Size(20, 20);
rectanglePrimitive.PositionOffset = new SizeF(15, 15);

Dim rectanglePrimitive As New BorderPrimitive()
rectanglePrimitive.ForeColor = Color.Red
rectanglePrimitive.MinSize = New Size(20, 20)
rectanglePrimitive.PositionOffset = New SizeF(15, 15)

See Also

In this article