I have a vertical StackPanel with two elements: a Button and a ListBox. How can I have the ListBox stretch to the remaining page height?
I agree with James' observation that "StackPanels won't fill any remaining space by default because their size is always equal to the combined required size of their child elements." That is exactly what happens, but this isn't the expected result.
I can see why this instruction would compress the contents into the smallest necessary space.
However... StackPanel accepts a HorizontalAlignment argument - which if selected should cause the stack panel to fill the contents of its parent container. This is exactly what happens when you set Orientation="Vertical". Observe that in this case the StackPanel will determine how much horizontal space is available and allocated it to the child controls.
Its only when Orientation="Horizontal" that the Horizontal child sizing breaks down.