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 内の 1 つ以上の要素の ActualHeight を使用して、関連する要素の 1 つまたは別の要素の 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();
    }
}

注釈

Note

ActualHeightProperty バッキング フィールドがありますが、ActualHeight はプロパティ変更通知を生成せず、依存関係プロパティではなく通常の CLR プロパティと考える必要があります。

ActualHeight は計算プロパティです。 計算はレイアウト パスの結果であり、オブジェクトは、その連続するレイアウト親のロジックに従ってレイアウトでサイズが設定されます。 詳細については、「 XAML を使用してレイアウトを定義する」を参照してください。

ActualHeight では、レイアウト システムによる操作により、値に対する複数または増分の変更を報告できます。 レイアウトの反復処理中に値を取得した場合でも、レイアウト システムでは、子オブジェクトに必要な領域のメジャー、親オブジェクトによる制約などを計算している可能性があります。 値は実際のレンダリング パスに基づいているため、 Height などのプロパティの設定値よりもわずかに遅れる可能性があります。これは、入力変更の基礎になる可能性があります。

ElementName バインドの目的で、ActualHeight は変更時に更新をポストしません (非同期および実行時の計算上の性質のため)。 ElementName バインドのバインド ソースとして ActualHeight を使用しないでください。 ActualHeight に基づく更新が必要なシナリオがある場合は、 SizeChanged ハンドラーを使用します。

適用対象

こちらもご覧ください