WPF 如何访问嵌套网格?

WPF How to access nested grid?

如何使用 Grid.Column 和 Grid.Row 访问嵌套的网格元素?通常,Grid.Column="1" Grid.Row="0" 是要走的路。但我不知道如何访问嵌套的?例如:第 0 列,嵌套第 3 列,第 1 行。

我添加了布局结构的图片: Grid Layout

<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center"  VerticalAlignment="Top" Width="87" Height="23" Text="btn" BorderThickness="1,1,0,1"  />

嵌套网格:

<Grid x:Name="LayoutRoot" Background="#FFA3A3A3" Height="540" Width="952" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="10"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
            <Grid Grid.Column="1" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="140*"/>
                    <ColumnDefinition Width="346*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="52*"/>
                        <RowDefinition Height="220.5*"/>
                    </Grid.RowDefinitions>
                </Grid>
            </Grid>
            <Grid Grid.Column="1" Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40*"/>
                    <ColumnDefinition Width="120*"/>
                    <ColumnDefinition Width="146*"/>
                    <ColumnDefinition Width="146*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

            </Grid>

                Some code...

                <Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center"  VerticalAlignment="Top" Width="87" Height="23" Text="btn" BorderThickness="1,1,0,1"  />

</Grid>

您 can/need 没有访问嵌套网格。 Grid.Column/Row 始终表示父网格。

<Grid x:Name="Grid1">
    <Grid x:Name="Grid2" Grid.Row="0", Grid.Columns="0">
        <TextBlock Grid.Row="0", Grid.Columns="0"> TextBlock in Grid2[0,0]</TextBlock>
    </Grid>
    <TextBlock Grid.Row="1", Grid.Columns="0"> TextBlock in Grid1[1,0]</TextBlock>
</Grid>

嵌套的Grid2在Grid1的[0,0]