Vertical Align in WPF TextBox

前端 未结 4 1349
灰色年华
灰色年华 2021-02-06 20:55

I have 2 TextBoxes in my wpf app, one for user name and other for password, both have FontSize=20, but the text appears like this:

4条回答
  •  野的像风
    2021-02-06 21:46

    The reason for this is because you have specified the FontSize property as well as the Height explicitly. The text with the bigger FontSize cannot fit in the given height. So, there are a couple of solutions for this

    1. Increase the Height of the TextBox to 60 (but this will create a heighted TextBox which may not look good in the UI). Or, you can just skip Height property, so that it will automatically take the minimum space it needs.
        
    
    1. Reduce FontSize, so that the text can fit in the TextBox with Height 40
        
    

提交回复
热议问题