本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

FrameworkElement.ActualHeight 屬性

 

取得這個項目的轉譯的高度。

命名空間:   System.Windows
組件:  PresentationFramework (於 PresentationFramework.dll)

public double ActualHeight { get; }

屬性值

Type: System.Double

項目的高度,以值 裝置獨立單位 (每單位 1/96 英吋)。 預設值為 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 起供應
回到頁首
顯示: