本文由机器翻译。若要查看英语原文,请勾选“英语”复选框。 也可将鼠标指针移到文本上,在弹出窗口中显示英语原文。
翻译
英语

FrameworkElement.Height 属性

 

获取或设置元素的建议高度。

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

[TypeConverterAttribute(typeof(LengthConverter))]
[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public double Height { get; set; }

属性值

Type: System.Double

元素的高度(以 与设备无关的单位(每个单位 1/96 英寸) 为单位)。 默认值为 Double.NaN 此值必须等于或大于 0.0。 请参阅“备注”以了解上限信息。

Height is one of three writable properties on FrameworkElement that specify height information. The other two are MinHeight and MaxHeight. If there is a conflict between these values, the order of application for actual height determination is that first MinHeight must be honored, then MaxHeight, and finally, if it is within bounds, Height.

If this element is a child element within some other element, then setting this property to a value is really only a suggested value. The layout system as well as the particular layout logic of the parent element will use the value as a nonbinding input during the layout process. In practical terms, a T:System.Windows.FrameworkElement is almost always the child element of something else; even when you set the P:System.Windows.FrameworkElement.Height on T:System.Windows.Window. (For T:System.Windows.Window, that value is used when the underlying application model establishes the basic rendering assumptions that create the Hwnd that hosts the application.)

In addition to acceptable T:System.Double values, this property can also be F:System.Double.NaN. This is how you specify auto sizing behavior in code. In TLA2#tla_xaml you set the value to the string "Auto" (case insensitive) to enable the auto sizing behavior. Auto sizing behavior implies that the element will fill the height available to it. Note however that specific controls frequently supply default values through their default theme styles that will disable the auto sizing behavior unless it is specifically re-enabled.

The return value of this property is always the same as any value that was set to it. In contrast, the value of the P:System.Windows.FrameworkElement.ActualHeight may vary. This can happen either statically because the layout rejected the suggested size for some reason, or momentarily. The layout system itself works asynchronously relative to the property system's set of P:System.Windows.FrameworkElement.Height and may not have processed that particular sizing property change yet.

The value restrictions on the T:System.Double value are enforced by a T:System.Windows.ValidateValueCallback mechanism. If you attempt to set an invalid value, a run-time exception is thrown.

In addition to the validation check, there is a nondeterministic upper value bound for P:System.Windows.FrameworkElement.Height that is enforced by the layout system (this is a very large number, larger than F:System.Single.MaxValue but smaller than F:System.Double.MaxValue). If you exceed this bound, the element will not render, and no exception is thrown. Do not set P:System.Windows.FrameworkElement.Height to a value that is significantly larger than the maximum size of any possible visual display, or you may exceed this nondeterministic upper bound.

<object Height="double"/>
- or -
<object Height="qualifiedDouble"/>
- or -
<object Height="Auto"/>

double

Double

String representation of a T:System.Double value equal to or greater than 0.0. See Remarks for upper bound information. This value is interpreted as a TLA#tla_dipixel measurement. Strings need not explicitly include decimal points. For instance a value of 1 is acceptable.

qualifiedDouble

A double value as described above, followed by one of the following unit declaration strings: px, in, cm, pt.

px (default) is 与设备无关的单位(每个单位 1/96 英寸)

in is inches; 1in==96px

cm is centimeters; 1cm==(96/2.54) px

pt is points; 1pt==(96/72) px

Auto

Enables autosizing behavior. See Remarks.

Identifier field

HeightProperty

Metadata properties set to true

AffectsMeasure

.NET Framework
自 3.0 起可用
Silverlight
自 2.0 起可用
Windows Phone Silverlight
自 7.0 起可用
返回页首
显示: