Table of Contents

Class StackPanel

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

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

StyledProperty<bool>

AreVerticalSnapPointsRegularProperty

Defines the AreVerticalSnapPointsRegular property.

public static readonly StyledProperty<bool> AreVerticalSnapPointsRegularProperty

Field Value

StyledProperty<bool>

HorizontalSnapPointsChangedEvent

Defines the HorizontalSnapPointsChanged event.

public static readonly RoutedEvent<RoutedEventArgs> HorizontalSnapPointsChangedEvent

Field Value

RoutedEvent<RoutedEventArgs>

OrientationProperty

Defines the Orientation property.

public static readonly StyledProperty<Orientation> OrientationProperty

Field Value

StyledProperty<Orientation>

SpacingProperty

Defines the Spacing property.

public static readonly StyledProperty<double> SpacingProperty

Field Value

StyledProperty<double>

VerticalSnapPointsChangedEvent

Defines the VerticalSnapPointsChanged event.

public static readonly RoutedEvent<RoutedEventArgs> VerticalSnapPointsChangedEvent

Field Value

RoutedEvent<RoutedEventArgs>

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

bool

AreVerticalSnapPointsRegular

Gets or sets whether the vertical snap points for the StackPanel are equidistant from each other.

public bool AreVerticalSnapPointsRegular { get; set; }

Property Value

bool

Orientation

Gets or sets the orientation in which child controls will be layed out.

public Orientation Orientation { get; set; }

Property Value

Orientation

Spacing

Gets or sets the size of the spacing to place between child controls.

public double Spacing { get; set; }

Property Value

double

Methods

ArrangeOverride(Size)

Content arrangement.

protected override Size ArrangeOverride(Size finalSize)

Parameters

finalSize Size

Arrange size

Returns

Size

GetControlInDirection(NavigationDirection, Control?)

Gets the next control in the specified direction.

protected virtual IInputElement? GetControlInDirection(NavigationDirection direction, Control? from)

Parameters

direction NavigationDirection

The movement direction.

from Control

The 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 Orientation

The orientation for the desired snap point set.

snapPointsAlignment SnapPointsAlignment

The 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 Orientation

The orientation for the desired snap point set.

snapPointsAlignment SnapPointsAlignment

The alignment to use when applying the snap points.

offset double

Out 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 Size

Constraint

Returns

Size

Desired size

Events

HorizontalSnapPointsChanged

Occurs when the measurements for horizontal snap points change.

public event EventHandler<RoutedEventArgs>? HorizontalSnapPointsChanged

Event Type

EventHandler<RoutedEventArgs>

VerticalSnapPointsChanged

Occurs when the measurements for vertical snap points change.

public event EventHandler<RoutedEventArgs>? VerticalSnapPointsChanged

Event Type

EventHandler<RoutedEventArgs>