Question

Lets say you have a WrapPanel with a labels:

<WrapPanel>
    <Label Content="My Label" HorizontalContentAlignment="Center" />
    <Label Content="My Label 2" HorizontalContentAlignment="Center" />
</WrapPanel>

Basically, I want each of these to fill a full line in the wrappanel. This seems like a simple thing to do, however, I can't seem to find out how.

I know that you can do it using the 'Width' property, however, I don't want a hard coded width.

Was it helpful?

Solution

If you want each label to be stacked, rather than wrapping, use a StackPanel instead of a WrapPanel:

<StackPanel>
    <Label Content="My Label" HorizontalContentAlignment="Center" />
    <Label Content="My Label 2" HorizontalContentAlignment="Center" />
</StackPanel>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top