how to calculate the textbock height and width in on load if i create textblock from code?

五迷三道 提交于 2019-11-27 09:16:49
Filip Skakun

Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated.

Can also do this via

UpdateLayout();
testBlock.ActualWidth

This could be useful when calculating multiple objects heights and widths.

TextBlock tbl = new TextBlock();
tbl.Text = "Kishore";

tbl.Measure(new Size(0, 0));

double x = tbl.ActualHeight;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!