我在运行时创建了一个 StackPanel
,我想要测量 StackPanel
的 Height
,代码如下:
StackPanel panel = new StackPanel();
panel.Children.Add(new Button() { Width = 75, Height = 25 });
Title = panel.ActualHeight.ToString();
但是ActualHeight
总是为零。我该如何测量StackPanel
的Height
?
ActualHeight
在渲染时将始终为25,因为StackPanel会无限增长以容纳其子元素。你想在这里实现什么? - Rohit Vats