Hi Is there any simple way to center a text in textbox?? I was looking for some build in functions but I found nothing.
A:
Set the HorizontalContentAlignment
property to Center
:
<TextBox Width="200"
Text="Hello world !"
HorizontalContentAlignment="Center"/>
Thomas Levesque
2010-08-15 01:05:53
Thanks for repy but it didn't work. However You gave me path which I followed and I used sth like this in my style <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="TextAlignment" Value="Center"/>HorizontalContentAlignment didn't work but code above did the trick.However another problem occured. Namely now if I click right mouse button on my textbox text in contextMenu is centered :(
noname
2010-08-15 09:24:42
Oh, I see... actually you should use only TextAlignment, not HorizontalContentAlignment
Thomas Levesque
2010-08-15 11:07:14