Class StackPanel
Arranges its Children in a single line, sequentially along Orientation.
public class StackPanel : Panel, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerElement, IContainerLayout
- Inheritance
-
StackPanel
- Implements
- Inherited Members
- Extension Methods
Remarks
Cross-axis placement (e.g. horizontal position within a Vertical stack) is left to each child's own HorizontalAlignment/VerticalAlignment and Margin, resolved against the full cross-axis extent of ContentBounds.
Properties
Orientation
Gets or sets the axis children are stacked along.
public Orientation Orientation { get; set; }
Property Value
Methods
ArrangeContent()
Handles custom arrange logic when overridden in any UIElement instance.
protected override void ArrangeContent()
Remarks
This method is called during the arrange pass to position and size the element's content within its final bounds. The element's position and size are already determined by the layout system and available in the ActualBounds property.
When implementing this method:
- Position child elements within the available space;
- Respect the element's padding when positioning content;
- Handle any content-specific layout requirements;
- Call Arrange() on child elements if needed.
MeasureContent()
Handles custom measure logic when overridden in any UIElement instance.
protected override Size MeasureContent()
Returns
Remarks
This method is called during the measure pass to determine the desired size of the element. The returned size should represent the natural size of the element's content, without considering any constraints, margins, or padding.
When implementing this method:
- Return the natural size needed to display the content;
- Do not include padding, margins, or borders in the returned size;
- Consider the content's actual dimensions (e.g., text length, image size);
- Return Empty if the element has no content.