Layout Item's Size Constraints vs. Client Area's Size Constraints
- 3 minutes to read
The Layout Control allows size constraints to be imposed either on a layout item or the item’s client area that displays a control. Additionally it’s possible to set size constraints to the control itself via its MaximumSize and MinimumSize properties. See Custom Size Constraints to learn more. The current topic describes how a layout item’s size constraints and its client area’s size constraints are linked.
Size constraints can be set via the following properties:
- The LayoutControlItem.MinSize and LayoutControlItem.MaxSize properties specify size constraints applied to the entire layout item.
The LayoutControlItem.ControlMinSize and LayoutControlItem.ControlMaxSize properties specify size constraints applied to the layout item’s client area.
In most instances, the control fills the layout item’s client area in its entirety. If this is the case, the LayoutControlItem.ControlMinSize and LayoutControlItem.ControlMaxSize properties specify size constraints for the client area and the control. If the control doesn’t fill the client area entirely, these properties specify size constraints only for the client area.
A layout item’s size constraints and client area’s size constraints are interdependent. When you change the item’s size constraints, the client area’s size constraints are automatically recalculated and vice versa. This is explained below.
A layout item consists of the following regions: inner and outer border indents, text region, control’s indent and client area which displays the item’s control. The image below shows which elements constitute the layout item’s width:
When a layout item is resized, the indents and text region’s size remain constant. In this case, the layout item’s client area is resized. The size constraints imposed on the layout item and its client area depend on each other. When the MinSize.Width property is changed, the ControlMinSize.Width property, which specifies the client area’s width, is recalculated as follows:
ControlMinSize.Width = MinSize.Width - (Left and right border inner and outer indents + Text region's width + Control's indent)
When the ControlMinSize.Width is set to a new value the MinSize.Width property is recalculated as follows:
MinSize.Width = ControlMinSize.Width + (Left and right border inner and outer indents + Text region's width + Control's indent)
The same considerations are applied to the MaxSize and ControlMaxSize properties. The Height attribute of the MinSize, ControlMinSize, MinSize and ControlMaxSize properties is calculated accordingly.
The text region can be displayed above or below the layout item’s client area or can be hidden completely. In this case, the Layout Control uses other formulas to calculate a layout item’s size constraints based on the client area’s size constraints and vice versa.
Note
The LayoutControlItem.MinSize, LayoutControlItem.MaxSize, LayoutControlItem.ControlMinSize and LayoutControlItem.ControlMaxSize properties can only be changed if the LayoutControlItem.SizeConstraintsType property is set to Custom. See the Custom Size Constraints topic for details.