【问题标题】:RowSpan "Auto" makes two rows merge for WP8.1RowSpan "Auto" 为 WP8.1 合并两行
【发布时间】:2014-10-19 20:42:12
【问题描述】:

我有一个网格,我在其中使用列定义创建了三行。在第一行中,我放置了一个带有矩形的网格并设置 Rowspan = 2。在第二行中,我还有一个带有矩形的网格。而不是第一行只是稍微重叠第二行,这是我希望的,它们完全重叠,似乎只有一行。

我已将行定义高度设置为自动,因为我希望稍后通过单击按钮来更改行的高度。

有没有办法避免使用 RowDefinition 的自动高度合并两行?

到目前为止我得到的代码是:

<Page
x:Class="GridRetreatTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:GridRetreatTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" Height="100" Grid.RowSpan="2">
        <Rectangle Fill="Blue"/>
    </Grid>
    <Grid Grid.Row="1" Height="100">
        <Rectangle Fill="Red"/>
    </Grid>
    <Grid Grid.Row="2" Height="100">
        <Rectangle Fill="Green"/>
    </Grid>
</Grid>

【问题讨论】:

    标签: xaml windows-phone-8 rowdefinition


    【解决方案1】:

    试试这个:

    XAML:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Height="100" >
            <Rectangle Fill="Blue"/>
        </Grid>
        <Grid x:Name="grd1" Grid.Row="1" Height="100" Margin="0,-50,0,0">
            <Rectangle Fill="Red"/>
        </Grid>
        <Grid Grid.Row="2" Height="100">
            <Rectangle Fill="Green"/>
        </Grid>
    </Grid>
    <StackPanel Grid.Row="4">
        <Button Content="click" Click="Button_Click"></Button>
    </StackPanel>
    

    CS:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        grd1.Margin = new Thickness(0, 0, 0, 0);
        grd1.Height = 300;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多