FrameworkElement.ActualHeight 속성

정의

이 요소의 렌더링된 높이를 가져옵니다.

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

속성 값

디바이스 독립적 단위(단위당 1/96인치)의 값으로 요소의 높이입니다. 기본값은 0입니다.

예제

다음 예제에서는 다양한 높이 속성을 표시합니다.

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

설명

이 속성은 다른 높이 입력 및 레이아웃 시스템을 기반으로 계산된 값입니다. 값은 실제 렌더링 패스에 따라 레이아웃 시스템 자체에 의해 설정되므로 입력 변경의 기초인 속성 Height 의 설정 값보다 약간 뒤쳐질 수 있습니다.

ActualHeight는 계산된 값이므로 레이아웃 시스템의 다양한 작업의 결과로 여러 번 점증적인 변경이 보고될 수 있습니다. 레이아웃 시스템은 자식 요소에 필요한 측정 공간, 부모 요소에 의한 제약 조건 등을 계산할 수도 있습니다.

XAML에서 이 속성을 설정할 수는 없지만 스타일에서 해당 값을 기반으로 Trigger 할 수 있습니다.

종속성 속성 정보

식별자 필드 ActualHeightProperty
메타 데이터 속성 설정 true 없음

적용 대상