Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

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

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

double x=tbl.ActualHeight;
double y=tbl.ActualWidth;

If i execute the code from the loaded event in Metro - winRT will return 0 for both.

How can I get the ActualWidth in the Loaded or SizeChanged event?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...