how to calculate the textbock height and width in on load if i create textblock from code?
-
07-06-2021 - |
Question
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?
OTHER TIPS
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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow