简体   繁体   中英

Get WPF control height when it is set 'Auto'

I need get a WPF control height for calculate my next control margin top, but when I try get control height with textbox1.height , this is return 'Auto' and not numbers

What can I do for get control height, when it is set 'Auto'?

You should try this:

textBox1.ActualHeight

Remarks (by @Viv)

just make sure when you query for textBox1.ActualHeight, you do it once the control is Loaded. You're going to get 0.0 if you check ActualHeight before it's setup properly

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