How to center tag text in WPF?

How to center label text in WPF?

Label HorizontalAlignment="Center" Content="What?" FontSize="25" FontWeight="Bold" Canvas.Top="5" 
+98
c # wpf
Mar 15 '11 at 17:23
source share
4 answers

use the HorizontalContentAlignment property.

Example

 <Label HorizontalContentAlignment="Center"/> 
+183
Mar 15 '11 at 17:26
source share

The Control class has the HorizontalContentAlignment and VerticalContentAlignment properties. These properties determine how the content of the control fills the space inside the control.
Set HorizontalContentAlignment and VerticalContentAlignment to Center.

+7
Mar 15 2018-11-17T00:
source share

Sample:

 Label label = new Label(); label.HorizontalContentAlignment = HorizontalAlignment.Center; 
0
Oct 14 '18 at 9:15
source share

You must use HorizontalContentAlignment = "Center" and! Width = "Auto".

0
Jul 04 '19 at 13:41
source share



All Articles