FrameworkElement.ActualHeight 속성

정의

FrameworkElement의 렌더링된 높이를 가져옵니다. 설명 부분을 참조하세요.

public:
 property double ActualHeight { double get(); };
double ActualHeight();
public double ActualHeight { get; }
var double = frameworkElement.actualHeight;
Public ReadOnly Property ActualHeight As Double

속성 값

Double

double

개체의 높이(픽셀)입니다. 기본값은 0입니다. 개체가 로드되지 않았고 UI를 렌더링하는 레이아웃 패스에 아직 관여하지 않은 경우 기본값이 발생할 수 있습니다.

예제

이 예제에서는 UI에 있는 하나 이상의 요소의 ActualHeight를 사용하여 관련된 요소 중 하나 또는 다른 요소 중 하나의 Height 를 설정하여 작업 후에 동일한 순 높이를 유지 관리하는 일반적인 시나리오를 보여줍니다. 이 작업은 일반적으로 요소가 열리거나 닫히거나 표시 영역이 변경될 때 호출되는 이벤트 처리기에 대한 응답으로 수행됩니다.

void SDKSample::WebViewControl::PageWithAppBar::BottomAppBar_Opened(Object^ sender, Object^ obj)
{
    // AppBar has Opened so we need to put the WebView back to its
    // original size/location.
    AppBar^ bottomAppBar = (AppBar^) sender;
    if (bottomAppBar != nullptr)
    {
        // Force layout so that we can guarantee that our AppBar's
        // actual height has height
        this->UpdateLayout();
        // Get the height of the AppBar
        double appBarHeight = bottomAppBar->ActualHeight;
        // Reduce the height of the WebView to allow for the AppBar
        WebView8->Height = WebView8->ActualHeight - appBarHeight;
        // Translate the WebView in the Y direction to reclaim the space occupied by the AppBar.  
        TranslateYOpen->To = -appBarHeight / 2.0;
        // Run our translate animation to match the AppBar
        OpenAppBar->Begin();
    }
}
void BottomAppBar_Opened(object sender, object e)
{
    // AppBar has Opened so we need to put the WebView back to its
    // original size/location.
    AppBar bottomAppBar = sender as AppBar;
    if (bottomAppBar != null)
    {
        // Force layout so that we can guarantee that our AppBar's
        // actual height has height
        this.UpdateLayout();
        // Get the height of the AppBar
        double appBarHeight = bottomAppBar.ActualHeight;
        // Reduce the height of the WebView to allow for the AppBar
        WebView8.Height = WebView8.ActualHeight - appBarHeight;
        // Translate the WebView in the Y direction to reclaim the space occupied by 
        // the AppBar.  Notice that we translate it by appBarHeight / 2.0.
        // This is because the WebView has VerticalAlignment and HorizontalAlignment
        // of 'Stretch' and when we reduce its size it reduces its overall size
        // from top and bottom by half the amount.
        TranslateYOpen.To = -appBarHeight / 2.0;
        // Run our translate animation to match the AppBar
        OpenAppBar.Begin();
    }
}
Private Sub BottomAppBar_Opened(sender As Object, e As Object)
    ' AppBar has Opened so we need to put the WebView back to its
    ' original size/location.
    Dim bottomAppBar As AppBar = TryCast(sender, AppBar)
    If bottomAppBar IsNot Nothing Then
        ' Force layout so that we can guarantee that our AppBar's
        ' actual height has height
        Me.UpdateLayout()
        ' Get the height of the AppBar
        Dim appBarHeight As Double = bottomAppBar.ActualHeight
        ' Reduce the height of the WebView to allow for the AppBar
        WebView8.Height = WebView8.ActualHeight - appBarHeight
        ' Translate the WebView in the Y direction to reclaim the space occupied by 
        ' the AppBar.  Notice that we translate it by appBarHeight / 2.0.
        ' This is because the WebView has VerticalAlignment and HorizontalAlignment
        ' of 'Stretch' and when we reduce its size it reduces its overall size
        ' from top and bottom by half the amount.
        TranslateYOpen.[To] = -appBarHeight / 2.0
        ' Run our translate animation to match the AppBar
        OpenAppBar.Begin()
    End If
End Sub

설명

참고

ActualHeightProperty 지원 필드가 있지만 ActualHeight는 속성 변경 알림을 발생시키지 않으며 종속성 속성이 아닌 일반 속성으로 간주되어야 합니다.

ActualHeight는 계산된 속성입니다. 계산은 레이아웃 단계의 결과이며, 개체는 연속 레이아웃 부모의 논리에 따라 레이아웃 크기가 조정됩니다. 자세한 내용은 XAML을 사용하여 레이아웃 정의를 참조하세요.

ActualHeight는 레이아웃 시스템의 작업으로 인해 값에 대해 여러 또는 증분으로 보고된 변경 내용을 가질 수 있습니다. 레이아웃이 계속 반복되는 동안 값을 가져오면 레이아웃 시스템에서 자식 개체에 필요한 공간 측정값, 부모 개체의 제약 조건 등을 계산할 수 있습니다. 값은 실제 렌더링 패스를 기반으로 하므로 입력 변경의 기초가 될 수 있는 Height와 같은 속성의 설정 값보다 약간 뒤쳐질 수 있습니다.

ElementName 바인딩을 위해 ActualHeight는 변경 시(비동기 및 런타임 계산 특성으로 인해) 업데이트를 게시하지 않습니다. ElementName 바인딩에 대한 바인딩 원본으로 ActualHeight를 사용하지 마세요. ActualHeight를 기반으로 업데이트해야 하는 시나리오가 있는 경우 SizeChanged 처리기를 사용합니다.

적용 대상

추가 정보

  • ActualWidth
  • Height
  • <xref:Windows.UI.Xaml.FrameworkElement.SizeChanged%0a(frameworkelement_sizechanged.md)>