2012-03-12 107 views
1

我有一个3个定义列的网格。有没有办法将第1列分成3个网格行而不影响其他2列?我试过定义RowDefinitions,但它跨越了所有3列。我不想那样。我只希望它影响1列。定义一个列网格内的行网格

+0

它是一个GridView控件?或常规表? – 2012-03-12 13:31:13

+0

你看过http://msdn.microsoft.com/en-us/library/window/apps/windows.ui.xaml.controls.grid.rowspan.aspx? – code4life 2012-03-12 14:09:51

回答

0

您应该使用嵌套的网格。将内部网格放入第1列并定义一些行:

<Grid Name="outerGrid"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition /> 
     <ColumnDefinition /> 
     <ColumnDefinition /> 
    </Grid.ColumnDefinitions> 
    <Grid Name="innerGrid" Grid.Column="0"> 
     <Grid.RowDefinitions> 
      <RowDefinition /> 
      <RowDefinition /> 
      <RowDefinition /> 
     </Grid.RowDefinitions> 
    </Grid> 
</Grid> 
1

不,您不能。如果您在Grid之内声明,那么它将适用于所有Columns

一两件事你可以做的是声明Grid第一Column内,在Grid

<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition/> 
     <ColumnDefinition/> 
     <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 

    <Grid Grid.Column="0"> 
     <Grid.RowDefinitions> 
      <RowDefinition/> 
      <RowDefinition/> 
      <RowDefinition/> 
     </Grid.RowDefinitions> 
    </Grid> 
</Grid> 
0

定义三行你可以试试这个布局:

<Grid ShowGridLines="True" > 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition></ColumnDefinition> 
     <ColumnDefinition></ColumnDefinition> 
     <ColumnDefinition></ColumnDefinition> 
    </Grid.ColumnDefinitions> 
    <Grid Grid.Column="0"> 
     <Grid.RowDefinitions> 
      <RowDefinition></RowDefinition> 
      <RowDefinition></RowDefinition> 
      <RowDefinition></RowDefinition>     
     </Grid.RowDefinitions> 
    </Grid> 
</Grid>