B-Rad
B-Rad

Reputation: 1557

How do you force a label to fill a WrapPanel line?

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.

Upvotes: 0

Views: 633

Answers (1)

Fenton
Fenton

Reputation: 250972

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>

Upvotes: 2

Related Questions