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

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

如果我从 Metro 中加载的事件中执行代码 - winRT 将为两者返回 0。

我怎样才能ActualWidth参加LoadedSizeChanged参加活动?

4

3 回答 3

10

调用Measure()然后Arrange()然后ActualWidthActualHeight将被更新。

于 2012-05-12T02:14:16.560 回答
1

也可以通过

UpdateLayout();
testBlock.ActualWidth

这在计算多个对象的高度和宽度时可能很有用。

于 2015-09-16T13:00:12.847 回答
0
TextBlock tbl = new TextBlock();
tbl.Text = "Kishore";

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

double x = tbl.ActualHeight;
于 2014-10-17T02:27:30.560 回答