Search code examples
c#windows-8windows-runtimewinrt-xamlactualwidth

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?


Solution

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