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? 回答1: Call Measure() then Arrange() and then ActualWidth and ActualHeight will be updated. 回答2: Can also do this via UpdateLayout(); testBlock.ActualWidth This could be useful when calculating multiple objects heights and widths. 回答3: