user8162574
user8162574

Reputation:

WPF Label Justify & Distribute Text

I have a Label just displaying a title.

How can I justify the text? and how can I distribute the text? Can I use a label or do I have to use another control?

Upvotes: 2

Views: 4671

Answers (2)

PetoMPP
PetoMPP

Reputation: 78

As Matt said you can only apply the Justify property on TextBlock, so the way to go is to put the TextBlock inside of the Label as below:

<Label
    Grid.Row="2"
    Grid.Column="2"
    Grid.ColumnSpan="4"
    VerticalAlignment="Center"
    HorizontalAlignment="Center"
    FontSize="26">
    <TextBlock 
        TextWrapping="Wrap"
        Text="Sample Text"
        TextAlignment="Justify"/>
</Label>

Upvotes: 0

Matt L.
Matt L.

Reputation: 768

Label doesn't have any text alignment property, however TextBlock does have text alignment properties so you can use justify if that's what you're looking for:

<TextBlock TextAlignment="Justify" />

Upvotes: 3

Related Questions