Windows Phone 8中的网格行定义出现问题

本文关键字:定义 问题 网格 Phone Windows | 更新日期: 2023-09-27 17:58:12

此处存在关键问题。在我的情况下,我为我的应用程序汇编了以下代码。不幸的是,它在布局上造成了更大的问题。即使我们把RowDefinitions和Auto放在一起,它也不考虑RowHeight,而是从下面到Windows Phone模拟器的底部。

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" x:Name="firstGrid" Tap="FirstGrid_OnTap"/>
            <Grid Grid.Row="1" Visibility="Collapsed">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Button Content="A"/>
                <Button Grid.Column="1" Content="B"/>
            </Grid>
        </Grid>
    </Grid>

加载页面时,它会用ImageBrush填充第一个网格。因此,每当用户点击第一个网格时,它只会通过启用第二个网格的可见性向网格再插入一行。第二个网格将有几个按钮。当我看到第二个网格时,我很惊讶,因为它隐藏在模拟器的底部。即使我做了一百次不同的尝试,我也无法深入研究它实际存在的主要问题。非常感谢您的帮助。

Windows Phone 8中的网格行定义出现问题

根据我的理解,你需要在代码中进行此更改,第一行应该是自动的,第二行应该是*。

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>