Class BoxLayout
Represents a layout panel that arranges child elements in a horizontal or vertical box layout with proportional sizing support.
Inherited Members
Namespace: Telerik.WinControls.Layouts
Assembly: Telerik.WinControls.dll
Syntax
public class BoxLayout : LayoutPanel, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode
Remarks
BoxLayout extends LayoutPanel to provide flexible box-based layout capabilities where child elements can be arranged in either horizontal or vertical orientation. Each child element can be assigned a proportion value that determines how much of the available space it should occupy relative to other children.
The layout supports proportional sizing through the ProportionProperty attached property, allowing for dynamic space distribution among child elements. Elements with higher proportion values receive more space than those with lower values.
BoxLayout is commonly used in complex UI layouts where precise control over space distribution is required, such as in toolbars, panels, and container controls that need to adapt to different sizes.
Constructors
BoxLayout()
Declaration
public BoxLayout()
Fields
OrientationProperty
Identifies the Orientation dependency property.
Declaration
public static readonly RadProperty OrientationProperty
Field Value
RadProperty
|
Remarks
This property determines whether child elements are arranged horizontally (in a row) or vertically (in a column) within the layout container.
ProportionProperty
Identifies the ProportionProperty attached dependency property.
Declaration
public static RadProperty ProportionProperty
Field Value
RadProperty
|
Remarks
This property is attached to child elements to specify their proportional size relative to other children in the layout. A value of 0.0 means the element uses its desired size, while positive values indicate proportional sharing of available space.
StripPositionProperty
Identifies the BoxLayout.StripPosition dependency property.
Declaration
public static readonly RadProperty StripPositionProperty
Field Value
RadProperty
|
Remarks
This property determines the position where new elements are added to the layout container, affecting the visual ordering of child elements.
Properties
Orientation
Gets or sets the orientation of the box layout, determining whether child elements are arranged horizontally or vertically.
Declaration
[RadPropertyDefaultValue("Orientation", typeof(BoxLayout))]
public Orientation Orientation { get; set; }
Property Value
System.Windows.Forms.Orientation
An System.Windows.Forms.Orientation value indicating the arrangement direction. The default value is System.Windows.Forms.Orientation.Horizontal. |
Remarks
When set to System.Windows.Forms.Orientation.Horizontal, child elements are arranged side by side from left to right. When set to System.Windows.Forms.Orientation.Vertical, child elements are arranged top to bottom.
Changing this property triggers a layout invalidation, causing all child elements to be repositioned according to the new orientation.
Methods
ArrangeOverride(SizeF)
arranges the children by a given criteria
Declaration
protected override SizeF ArrangeOverride(SizeF finalSize)
Parameters
System.Drawing.SizeF
finalSize
|
Returns
System.Drawing.SizeF
|
Overrides
GetProportion(RadElement)
Gets the proportion value of the specified element.
Declaration
public static float GetProportion(RadElement element)
Parameters
RadElement
element
The element whose proportion value will be retrieved. |
Returns
System.Single
A float value representing the element's proportion relative to other elements in the layout. |
Remarks
The proportion value determines how much of the available space an element should occupy relative to other elements. A value of 0.0 means the element uses its desired size, while positive values indicate proportional sharing of remaining space.
Exceptions
System.ArgumentNullException
Thrown when |
InitializeFields()
MeasureOverride(SizeF)
measures the size to layout the children
Declaration
protected override SizeF MeasureOverride(SizeF availableSize)
Parameters
System.Drawing.SizeF
availableSize
|
Returns
System.Drawing.SizeF
|
Overrides
OnPropertyChanged(RadPropertyChangedEventArgs)
Handles the properties values changes of BoxLayout
Declaration
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
Parameters
RadPropertyChangedEventArgs
e
|
Overrides
SetProportion(RadElement, Single)
Sets the proportion value for the specified element (attached property).
Declaration
public static void SetProportion(RadElement element, float proportion)
Parameters
RadElement
element
The element whose proportion value will be set. |
System.Single
proportion
The proportion value to assign to the element. Should be a positive value or 0.0. |
Remarks
This method sets the attached property that controls how much space the element should occupy relative to other elements in the BoxLayout. The proportion value works as follows:
- 0.0: The element uses its desired/natural size
- Positive values: The element shares available space proportionally with other elements
For example, if three elements have proportions of 1.0, 2.0, and 1.0 respectively, the middle element will receive twice as much space as the other two.