Computer Magic Logo
Text alignment

Sunday, April 10, 2016

Published by Aristotelis Pitaridis

The controls have two properties which allow us to change the alignment of the text.

<Label x:Name="MyLabel" Text="Label" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />

We can change the text alignment programmatically using the following code.

MyLabel.HorizontalTextAlignment = TextAlignment.Center;
MyLabel.VerticalTextAlignment = TextAlignment.Center;