FrameworkElement.ActualHeight FrameworkElement.ActualHeight FrameworkElement.ActualHeight FrameworkElement.ActualHeight Property

定義

取得呈現此項目的高度。Gets the rendered height of this element.

public:
 property double ActualHeight { double get(); };
public double ActualHeight { get; }
member this.ActualHeight : double
Public ReadOnly Property ActualHeight As Double

屬性值

項目的高度,做為裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 內的值。The element's height, as a value in 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit). 預設值是 0 (零)。The default value is 0 (zero).

範例

下列範例會顯示各種高度屬性。The following example displays various height properties.

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;
}
Private Sub changeHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)
    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.Height = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub
Private Sub changeMinHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)

    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.MinHeight = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub
Private Sub changeMaxHeight(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)

    Dim li As ListBoxItem = CType(CType(sender, ListBox).SelectedItem, ListBoxItem)
    Dim sz1 As Double = Double.Parse(li.Content.ToString())
    rect1.MaxHeight = sz1
    rect1.UpdateLayout()
    txt1.Text = "ActualHeight is set to " + rect1.ActualHeight.ToString
    txt2.Text = "Height is set to " + rect1.Height.ToString
    txt3.Text = "MinHeight is set to " + rect1.MinHeight.ToString
    txt4.Text = "MaxHeight is set to " + rect1.MaxHeight.ToString
End Sub

備註

這個屬性是根據其他高度輸入和版面配置系統的導出的值。This property is a calculated value based on other height inputs, and the layout system. 值,由配置系統本身根據實際轉譯階段,並可能因此會落後稍有設定的值屬性的這類Height所輸入變更的基礎。The value is set by the layout system itself, based on an actual rendering pass, and may therefore lag slightly behind the set value of properties such as Height that are the basis of the input change.

因為ActualHeight是計算的值,您應該注意可能是多個,或是設定報告的累加式變更為其各種作業的結果由配置系統。Because ActualHeight is a calculated value, you should be aware that there could be multiple or incremental reported changes to it as a result of various operations by the layout system. 配置系統可能會計算子項目所需的測量空間、父項目的條件約束,依此類推。The layout system may be calculating required measure space for child elements, constraints by the parent element, and so on.

雖然您無法設定這個屬性從XAMLXAML,您可以根據Trigger其樣式中的值。Although you cannot set this property from XAMLXAML, you can base a Trigger upon its value in a style.

相依性屬性資訊Dependency Property Information

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

適用於