StackPanel Class
Represents a panel that can stack child controls horizontally or vertically, based on the current variant size.
public class StackPanel : Panel, IVariantControl
- Inheritance:
- object Visual UIElement FrameworkElement Panel object
- Implements:
- IVariantControl
Remarks
For detailed documentation on this control's features and how to use them, please see the StackPanel documentation topic.
Constructors
StackPanel()
Initializes an instance of the class.
public StackPanel()
Properties
Context
Gets or sets a ControlContext that describes the current context of the control.
public ControlContext Context { get; set; }
Property Value
- ControlContext:
A ControlContext that describes the current context of the control. The default value is
ControlContext.RibbonTabGroupItem
.
HorizontalContentAlignment
Gets or sets a HorizontalAlignment that indicates how to align items horizontally when in a vertical layout.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
- HorizontalAlignment:
A HorizontalAlignment that indicates how to align items horizontally when in a vertical layout. The default value is
HorizontalAlignment.Left
.
Remarks
Only Left
and Stretch
are recognized values.
ItemVariantBehavior
Gets or sets a StackPanelItemVariantBehavior that specifies how child controls are assigned variants based on the current value of the VariantSize property.
public StackPanelItemVariantBehavior ItemVariantBehavior { get; set; }
Property Value
- StackPanelItemVariantBehavior:
A StackPanelItemVariantBehavior that specifies how child controls are assigned variants based on the current value of the VariantSize property. The default value is
StackPanelItemVariantBehavior.Default
.
Remarks
See the StackPanelItemVariantBehavior description for details on how various settings of this property affect child control variants.
ItemVariantSize
Gets a VariantSize that specifies the variant size of contained controls based on the panel's current VariantSize.
public VariantSize ItemVariantSize { get; }
Property Value
- VariantSize:
A VariantSize that specifies the variant size of contained controls based on the panel's current VariantSize.
RowAlignment
Gets or sets a StackPanelRowAlignment specifying the vertical alignment of rows within the StackPanel.
public StackPanelRowAlignment RowAlignment { get; set; }
Property Value
- StackPanelRowAlignment:
A StackPanelRowAlignment specifying the vertical alignment of rows within the StackPanel. The default value is
StackPanelRowAlignment.Top
.
VariantSize
Gets or sets a VariantSize that indicates the control's current variant size.
public VariantSize VariantSize { get; set; }
Property Value
- VariantSize:
A VariantSize that indicates the control's current variant size. The default value is
VariantSize.Large
.
Methods
ArrangeOverride(Size)
When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.
protected override Size ArrangeOverride(Size finalSize)
Parameter | Type | Description |
---|---|---|
finalSize | Size | The final area within the parent that this element should use to arrange itself and its children. |
Returns
- Size:
The actual size used.
MeasureOverride(Size)
When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.
protected override Size MeasureOverride(Size availableSize)
Parameter | Type | Description |
---|---|---|
availableSize | Size | The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available. |
Returns
- Size:
The size that this element determines it needs during layout, based on its calculations of child element sizes.
OnCreateAutomationPeer()
Creates and returns an AutomationPeer object for this type.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer:
The AutomationPeer that was created.
OnRender(DrawingContext)
When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
protected override void OnRender(DrawingContext drawingContext)
Parameter | Type | Description |
---|---|---|
drawingContext | DrawingContext | The drawing instructions for a specific element. This context is provided to the layout system. |
OnVisualChildrenChanged(DependencyObject, DependencyObject)
Called when the visual children collection of the visual object is modified.
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
Parameter | Type | Description |
---|---|---|
visualAdded | DependencyObject | The Visual that was removed from the collection. |
visualRemoved | DependencyObject | The Visual that was removed from the collection. |
Fields
ContextProperty
Identifies the Context dependency property. This field is read-only.
public static readonly DependencyProperty ContextProperty
HorizontalContentAlignmentProperty
Identifies the HorizontalContentAlignment dependency property. This field is read-only.
public static readonly DependencyProperty HorizontalContentAlignmentProperty
ItemVariantBehaviorProperty
Identifies the ItemVariantBehavior dependency property. This field is read-only.
public static readonly DependencyProperty ItemVariantBehaviorProperty
ItemVariantSizeProperty
Identifies the ItemVariantSize dependency property. This field is read-only.
public static readonly DependencyProperty ItemVariantSizeProperty
RowAlignmentProperty
Identifies the RowAlignment dependency property. This field is read-only.
public static readonly DependencyProperty RowAlignmentProperty
VariantSizeProperty
Identifies the VariantSize dependency property. This field is read-only.
public static readonly DependencyProperty VariantSizeProperty