FrameworkElement.MaxHeight 속성

정의

FrameworkElement의 최대 높이 제약 조건을 가져오거나 설정합니다.

public:
 property double MaxHeight { double get(); void set(double value); };
double MaxHeight();

void MaxHeight(double value);
public double MaxHeight { get; set; }
var double = frameworkElement.maxHeight;
frameworkElement.maxHeight = double;
Public Property MaxHeight As Double
<frameworkElement MaxHeight="double"/>
 

속성 값

Double

double

개체의 최대 높이(픽셀)입니다. 기본값은 PositiveInfinity입니다. 이 값은 0보다 크거나 같은 값일 수 있습니다. PositiveInfinity 도 유효합니다.

예제

이 XAML 예제에서는 ViewBox에 MaxHeight를 지정하는 기술을 보여 줍니다. ViewBox 는 레이아웃 정보를 단일 자식에 적용하고 다음 부모 요소(이 경우 StackPanel)의 레이아웃 영역을 나눌 수 있는 데코레이터입니다.

<Grid Height="600" Width="600">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    
    <StackPanel Grid.Row="0" Grid.Column="0" Margin="5,5,5,5" Orientation="Vertical">
        <TextBlock Text="Stretch" FontWeight="Bold" FontSize="12" />
        <Button Name="btn1" Click="stretchNone" Content="None" />
        <Button Name="btn2" Click="stretchFill" Content="Fill" />
        <Button Name="btn3" Click="stretchUni" Content="Uniform" />
        <Button Name="btn4" Click="stretchUniFill" Content="UniformToFill" />
    </StackPanel>

    <StackPanel Grid.Row="0" Grid.Column="1" Margin="5,5,5,5" Orientation="Vertical">
        <TextBlock Text="StretchDirection" FontWeight="Bold" FontSize="12" />
        <Button Name="btn5" Click="sdUpOnly" Content="UpOnly" />
        <Button Name="btn6" Click="sdDownOnly" Content="DownOnly" />
        <Button Name="btn7" Click="sdBoth" Content="Both" />
    </StackPanel>

    <StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" 
                Orientation="Vertical">
        <TextBlock Name="txt1" FontSize="12" FontWeight="Bold" />
        <TextBlock Name="txt2" FontSize="12" FontWeight="Bold" />
    </StackPanel>   

    <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" 
                Orientation="Horizontal">
        <Viewbox MaxWidth="100" MaxHeight="100" Name="vb1">
            <Image Source="flower.jpg"/>
        </Viewbox>
        <Viewbox MaxWidth="200" MaxHeight="200" Name="vb2">
            <Image Source="flower.jpg"/>
        </Viewbox>
        
        <Viewbox MaxWidth="300" MaxHeight="300" Name="vb3">
            <Image Source="flower.jpg"/>
        </Viewbox>
    </StackPanel>

</Grid>

설명

MaxHeight는 높이 정보를 지정하는 FrameworkElement 의 세 가지 쓰기 가능한 속성 중 하나입니다. 다른 두 가지는 HeightMinHeight입니다. 이러한 값 간에 충돌이 있는 경우 실제 높이 결정에 대한 애플리케이션 순서는 첫 번째 MinHeight 를 적용한 다음 MaxHeight를 적용하고 마지막으로 범위 내에 있는 경우 Height를 적용해야 한다는 것입니다. 이러한 모든 속성은 개체 트리에서 요소의 부모 레이아웃 동작에 대한 권장 사항입니다. 레이아웃 실행 후 개체의 높이는 ActualHeight 속성 값으로 사용할 수 있습니다.

요소의 최종 ActualHeight 가 MaxHeight를 초과할 수 있습니다. 예를 들어 UseLayoutRoundingtrue 로 설정되고 앱이 해상도 크기가 100% 이상인 디스플레이에서 실행 중인 경우 크기가 조정될 때 UI가 흐리게 표시되지 않도록 ActualHeight 가 반올림될 수 있습니다.

적용 대상

추가 정보