How to center a label text in WPF?

alansiqueira27 picture alansiqueira27 · Mar 15, 2011 · Viewed 133.4k times · Source

How to center a label text in WPF?


Label HorizontalAlignment="Center" Content="What?" FontSize="25" FontWeight="Bold" Canvas.Top="5"

Answer

biju picture biju · Mar 15, 2011

use the HorizontalContentAlignment property.

Sample

<Label HorizontalContentAlignment="Center"/>