英語で読む

次の方法で共有


FrameworkElement.ActualHeight プロパティ

定義

この要素の描画時の高さを取得します。

C#
public double ActualHeight { get; }

プロパティ値

デバイスに依存しない単位 (1 ユニットあたり 1/96 インチ) の値としての要素の高さ。 既定値は 0 (ゼロ) です。

次の例では、さまざまな高さのプロパティを表示します。

C#
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;
}

注釈

このプロパティは、他の高さの入力とレイアウト システムに基づいて計算された値です。 この値は、実際のレンダリング パスに基づいてレイアウト システム自体によって設定されるため、入力変更の基礎である などの Height プロパティの設定値よりもわずかに遅れる可能性があります。

ActualHeight は計算された値であるため、レイアウト システムによるさまざまな操作の結果として、その値に対して複数の変更や増分変更が報告される可能性があることにご注意ください。 レイアウト システムが、子要素に必要な測定スペース、親要素による制約などを計算している場合があります。

XAML からこのプロパティを設定することはできませんが、スタイルの値に 基づいて Trigger を設定できます。

依存プロパティ情報

識別子フィールド ActualHeightProperty
に設定されたメタデータ プロパティ true なし

適用対象

製品 バージョン
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9