ActualHeight 属性
此文章由机器翻译。 将光标移到文章的句子上,以查看原文。 更多信息。
译文
原文

FrameworkElement.ActualHeight 属性

 

获取此元素的呈现高度。

命名空间:   System.Windows
程序集:  PresentationFramework(PresentationFramework.dll 中)

public double ActualHeight { get; }

属性值

Type: System.Double

元素的高度,这是一个采用device-independent units (1/96th inch per unit)的值。默认值为 0(零)。

此属性是基于其他高度输入和布局系统进行计算的值。该值是由布局系统本身基于实际呈现处理过程设置的,因此可能稍微小于属性(例如作为输入更改基础的 Height)的设置值。

由于 ActualHeight 是一个计算值,因此您应该知道,作为布局系统各种操作的结果,该值可能有多次或递增的报告的更改。布局系统可能正在计算子元素所需的测量空间、父元素的约束等。

尽管您无法从 XAML 中设置此属性,但可以使 Trigger 基于此属性在某种样式中的值。

标识符字段

ActualHeightProperty

设置为 true 的元数据属性

下面的示例显示了各种高度属性。

private void changeHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.Height = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMinHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MinHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMaxHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MaxHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}

.NET Framework
3.0 后可用
Silverlight
2.0 后可用
Windows Phone Silverlight
7.0 后可用
返回页首
显示:
© 2016 Microsoft