'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?
Solution 1:[1]
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" />
Solution 2:[2]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt L. |
Solution 2 | PetoMPP |