Textbox - horizontal text centering
Set the TextAlignment
property to Center
:
<TextBox Width="200"
Text="Hello world !"
TextAlignment="Center"/>
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
You can reach the text within a WPF-TextBox with the combination VerticalAlignment and VerticalContentAlignment. You set the content to center and the total height with Stretch to the size of the comprehensive element like a grid row
<TextBox VerticalAlignment="Stretch" VerticalContentAlignment="Center">
Test
</TextBox>
it's too late but this may be helpful for someone
Try adding this two peoperties to your control
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"