I am looking for a good way to design a multi-column layout which reflows the controls in the columns according to the space available. I have a list of labels and fields which display information, and sometimes the view they are contained in needs to be tall and skinny, other times short and wide.
A simple solution is to use a WrapPanel
:
<WrapPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label>Some label:</Label>
<TextBlock>Some value</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label>Some other label:</Label>
<TextBlock>Some bigger value</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label>A:</Label>
<TextBlock>B</TextBlock>
</StackPanel>
</WrapPanel>
I want the labels and values all to line up horizontally into columns, without specifying a static width. Right now the Label
s and TextBlock
s are just sized based on their content.