在Xaml中设置最小或最大网格行高度(Xamarin.Forms)

在Xaml中设置最小或最大网格行高度(Xamarin.Forms)

问题描述:

我需要使用Xaml或后面的代码在Xamarin.Forms中设置GridRowDefinition的最小高度.我没有找到任何类似MinHeight或MaxHeight的属性. RowDefinition只有高度属性.

I need to set minimum height of a RowDefinition of Gridin Xamarin.Forms using Xaml or code behind. I didn't find any property like MinHeight or MaxHeight. There is only Height property for RowDefinition.

<Grid ColumnSpacing="10" Padding="20">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
</Grid>

您可以执行以下操作来设置您的MinimumHeight:

You can do this to set your MinimumHeight:

<Grid ColumnSpacing="10" Padding="20">
    <Grid.RowDefinitions>
        <RowDefinition Height= "Auto"/>
    </Grid.RowDefinitions>
    <ContentView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" MinimumHeightRequest="20">
        ...
    </ContentView>
</Grid>

注意:MinimumHeightRequest将在要求的高度要求的最小高度之间选择最小值. 来源

Note: The MinimumHeightRequest will chose the minimum between your requested height and your requested minimum height. Source