Sutton Mehaffey
Sutton Mehaffey

Reputation: 21

defining row grids within a column grid

I have a grid with 3 defined columns. Is there a way to divide column 1 into 3 grid rows without affecting the other 2 columns? I've tried defining RowDefinitions, but it spans all 3 columns. I don't want that. I only want it to affect the 1 column.

Upvotes: 2

Views: 2729

Answers (3)

ionden
ionden

Reputation: 12776

You could try this layout:

<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>

Upvotes: 0

Haris Hasan
Haris Hasan

Reputation: 30097

No, you cannot. If you declare a Row inside Grid it will be for all the Columns.

One thing you can do is declare a Grid inside the first Column and define three rows in that Grid

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

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

Upvotes: 2

Clemens
Clemens

Reputation: 128060

You should use nested Grids. Put an inner Grid into column 1 and define some rows:

<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>

Upvotes: 0

Related Questions