Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a WPF StackPanel fill vertically from bottom to top?

Tags:

wpf

stackpanel

I need to be able to fill a stackpanel with buttons but the buttons must appear at the bottom of the stackpanel first and populate upwards. The buttons are created dynamically and there's an unknown number of them so visual hackery just won't work. I've tried experimenting with vertical alignments but to no avail.

like image 709
EightyOne Unite Avatar asked Jan 29 '09 13:01

EightyOne Unite


People also ask

What is the difference between StackPanel and DockPanel?

For example, the order of child elements can affect their size in a DockPanel but not in a StackPanel. This is because StackPanel measures in the direction of stacking at PositiveInfinity, whereas DockPanel measures only the available size. The following example demonstrates this key difference.

What does StackPanel do in WPF?

The StackPanel in WPF is a simple and useful layout panel. It stacks its child elements below or beside each other, dependening on its orientation. This is very useful to create any kinds of lists. All WPF ItemsControls like ComboBox , ListBox or Menu use a StackPanel as their internal layout panel.

What is StackPanel in XAML?

StackPanel is a layout panel that arranges child elements into a single line that can be oriented horizontally or vertically. By default, StackPanel stacks items vertically from top to bottom in the order they are declared. You can set the Orientation property to Horizontal to stack items from left to right.


1 Answers

Like so:

<StackPanel VerticalAlignment="Bottom">     ... </StackPanel> 

and to populate with buttons upward you must insert the buttons at position 0, instead of adding them.

like image 147
Pop Catalin Avatar answered Oct 13 '22 08:10

Pop Catalin