FrameworkElement.Height FrameworkElement.Height FrameworkElement.Height FrameworkElement.Height Property

定義

取得或設定項目的建議高度。Gets or sets the suggested height of the element.

public:
 property double Height { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public double Height { get; set; }
member this.Height : double with get, set
Public Property Height As Double

屬性值

項目的高度 (以 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 為單位)。The height of the element, in 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit). 預設值為 NaNThe default value is NaN. 這個值必須等於或大於 0.0。This value must be equal to or greater than 0.0.

備註

Height 其中三個可寫入屬性位於FrameworkElement指定高度資訊。Height is one of three writable properties on FrameworkElement that specify height information. 其他兩種方式MinHeightMaxHeightThe other two are MinHeight and MaxHeight. 如果沒有之間有衝突,這些值,實際高度判斷的應用程式的順序是第一個MinHeight必須能被接受,然後MaxHeight,最後,如果在範圍中,內HeightIf 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. 實際上FrameworkElement幾乎都是其他; 的子項目設定時,即使HeightWindowIn practical terms, a FrameworkElement is almost always the child element of something else; even when you set the Height on Window. (如Window,會使用值,當基礎的應用程式模型會建立基本的轉譯假設建立 Hwnd 裝載的應用程式。)(For Window, that value is used when the underlying application model establishes the basic rendering assumptions that create the Hwnd that hosts the application.)

除了為可接受Double值,這個屬性也可以是Double.NaNIn addition to acceptable Double values, this property can also be Double.NaN. 這是您在程式碼中指定自動調整大小行為的方式。This is how you specify auto sizing behavior in code. XAMLXAML您將值設定為字串"Auto"(不區分大小寫) 若要啟用自動調整大小行為。In XAMLXAML 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. 相較之下,windows 7ActualHeight而有所不同。In contrast, the value of the ActualHeight may vary. 這種情形是以靜態方式配置拒絕建議的大小,基於某些原因,因為或立刻顯示。This can happen either statically because the layout rejected the suggested size for some reason, or momentarily. 版面配置系統本身會在相對於屬性系統的組以非同步方式運作Height和可能處理該特定尚未調整大小屬性變更。The layout system itself works asynchronously relative to the property system's set of Height and may not have processed that particular sizing property change yet.

值的限制Double值會強制執行ValidateValueCallback機制。The value restrictions on the Double value are enforced by a ValidateValueCallback mechanism. 如果您嘗試設定無效的值,則會擲回執行階段例外狀況。If you attempt to set an invalid value, a run-time exception is thrown.

驗證檢查,除了沒有不具決定性的上限值,用於繫結Height,會由配置系統強制執行 (這是非常大數目,大於Single.MaxValue但小於Double.MaxValue)。In addition to the validation check, there is a nondeterministic upper value bound for Height that is enforced by the layout system (this is a very large number, larger than Single.MaxValue but smaller than Double.MaxValue). 如果您超過此限制,將不會呈現項目,並擲回任何例外狀況。If you exceed this bound, the element will not render, and no exception is thrown. 請勿設定Height大幅超過大小上限的任何可能的視覺顯示,或者您可能會超過此不具決定性的上限值。Do not set 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.

XAML Attribute UsageXAML Attribute Usage

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

XAML 值XAML Values

doubledouble
Double

字串表示法Double等於或大於 0.0 的值。String representation of a Double value equal to or greater than 0.0. 如需上限資訊,請參閱<備註>。See Remarks for upper bound information. 這個值會解譯為裝置獨立單位 (1/96 英吋)device-independent unit (1/96th inch)度量。This value is interpreted as a 裝置獨立單位 (1/96 英吋)device-independent unit (1/96th inch) measurement. 字串不需要明確包含小數位數。Strings need not explicitly include decimal points. 執行個體的值1是可以接受的。For instance a value of 1 is acceptable.

qualifiedDoublequalifiedDouble
A值,如上所述,後面接著一個的下列單位宣告字串: pxincmptA double value as described above, followed by one of the following unit declaration strings: px, in, cm, pt.

px (預設值) 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit)px (default) is 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit)

in 是英吋為單位;1in = = 96pxin is inches; 1in==96px

cm 是公釐。1cm==(96/2.54) 像素cm is centimeters; 1cm==(96/2.54) px

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

AutoAuto
啟用自動調整大小行為。Enables autosizing behavior. 請參閱<備註>。See Remarks.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field HeightProperty
若要設定的中繼資料屬性 trueMetadata properties set to true AffectsMeasure

適用於

另請參閱