简体   繁体   中英

How to display text alignment to top, when WPF text box is a multiline

当我使用多行文本框时,文本框的文本/内容应该对齐到顶部,如果它是单行文本框,那么它的文本对齐方式应该是默认的(居中),我需要在文本框样式中设置它,所以当有一个多行文本框时,我的样式会相应地自动调整内容。

you only need to set VerticalContentAlignment="Top" in your textbox like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM