How to display text top alignment when WPF textbox is multiline

When I use a multi-line textbox the text / content of the textbox should be top-aligned, and if it is a textbox on one line then the text alignment should be the default (Center), I need to set this to the textbox style, so when there is multi-line textbox, my style automatically adjusts the content accordingly.

Thanks Advance Srinivas.

+3


source to share


1 answer


you only need to set VerticalContentAlignment="Top"

to the textbox like:



<TextBox     
    TextWrapping="Wrap" 
    AcceptsReturn="True" 
    Text="sample ... "
    VerticalContentAlignment="Top"                                
/>

      

+2


source







All Articles