views:

28

answers:

1

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
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
Oh, I see... actually you should use only TextAlignment, not HorizontalContentAlignment
Thomas Levesque