Class StackPanel
A panel which lays out its children horizontally or vertically.
public class StackPanel : Panel, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider, INavigableContainer, IScrollSnapPointsInfo
- Inheritance
-
StackPanel
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
StackPanel()
public StackPanel()
Fields
AreHorizontalSnapPointsRegularProperty
Defines the AreHorizontalSnapPointsRegular property.
public static readonly StyledProperty<bool> AreHorizontalSnapPointsRegularProperty
Field Value
AreVerticalSnapPointsRegularProperty
Defines the AreVerticalSnapPointsRegular property.
public static readonly StyledProperty<bool> AreVerticalSnapPointsRegularProperty
Field Value
HorizontalSnapPointsChangedEvent
Defines the HorizontalSnapPointsChanged event.
public static readonly RoutedEvent<RoutedEventArgs> HorizontalSnapPointsChangedEvent
Field Value
OrientationProperty
Defines the Orientation property.
public static readonly StyledProperty<Orientation> OrientationProperty
Field Value
SpacingProperty
Defines the Spacing property.
public static readonly StyledProperty<double> SpacingProperty
Field Value
VerticalSnapPointsChangedEvent
Defines the VerticalSnapPointsChanged event.
public static readonly RoutedEvent<RoutedEventArgs> VerticalSnapPointsChangedEvent
Field Value
Properties
AreHorizontalSnapPointsRegular
Gets or sets whether the horizontal snap points for the StackPanel are equidistant from each other.
public bool AreHorizontalSnapPointsRegular { get; set; }
Property Value
AreVerticalSnapPointsRegular
Gets or sets whether the vertical snap points for the StackPanel are equidistant from each other.
public bool AreVerticalSnapPointsRegular { get; set; }
Property Value
Orientation
Gets or sets the orientation in which child controls will be layed out.
public Orientation Orientation { get; set; }
Property Value
Spacing
Gets or sets the size of the spacing to place between child controls.
public double Spacing { get; set; }
Property Value
Methods
ArrangeOverride(Size)
Content arrangement.
protected override Size ArrangeOverride(Size finalSize)
Parameters
finalSize
SizeArrange size
Returns
GetControlInDirection(NavigationDirection, Control?)
Gets the next control in the specified direction.
protected virtual IInputElement? GetControlInDirection(NavigationDirection direction, Control? from)
Parameters
direction
NavigationDirectionThe movement direction.
from
ControlThe control from which movement begins.
Returns
- IInputElement
The control.
GetIrregularSnapPoints(Orientation, SnapPointsAlignment)
Returns the set of distances between irregular snap points for a specified orientation and alignment.
public IReadOnlyList<double> GetIrregularSnapPoints(Orientation orientation, SnapPointsAlignment snapPointsAlignment)
Parameters
orientation
OrientationThe orientation for the desired snap point set.
snapPointsAlignment
SnapPointsAlignmentThe alignment to use when applying the snap points.
Returns
- IReadOnlyList<double>
The read-only collection of snap point distances. Returns an empty collection when no snap points are present.
GetRegularSnapPoints(Orientation, SnapPointsAlignment, out double)
Gets the distance between regular snap points for a specified orientation and alignment.
public double GetRegularSnapPoints(Orientation orientation, SnapPointsAlignment snapPointsAlignment, out double offset)
Parameters
orientation
OrientationThe orientation for the desired snap point set.
snapPointsAlignment
SnapPointsAlignmentThe alignment to use when applying the snap points.
offset
doubleOut parameter. The offset of the first snap point.
Returns
- double
The distance between the equidistant snap points. Returns 0 when no snap points are present.
MeasureOverride(Size)
General StackPanel layout behavior is to grow unbounded in the "stacking" direction (Size To Content). Children in this dimension are encouraged to be as large as they like. In the other dimension, StackPanel will assume the maximum size of its children.
protected override Size MeasureOverride(Size availableSize)
Parameters
availableSize
SizeConstraint
Returns
- Size
Desired size
Events
HorizontalSnapPointsChanged
Occurs when the measurements for horizontal snap points change.
public event EventHandler<RoutedEventArgs>? HorizontalSnapPointsChanged
Event Type
VerticalSnapPointsChanged
Occurs when the measurements for vertical snap points change.
public event EventHandler<RoutedEventArgs>? VerticalSnapPointsChanged