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

EightyOne Unite picture EightyOne Unite · Jan 29, 2009 · Viewed 33.3k times · Source

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.

Answer

Pop Catalin picture Pop Catalin · Jan 29, 2009

Like so:

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

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