Adam McMahon
Adam McMahon

Reputation: 800

How to offset the Y position of every second column in a Grid Control

So, this is a standard 5x6 Grid.

<Grid Width="600" Height="840" >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/> 
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
    </Grid.RowDefinitions>
</Grid>

Which produces something like this:

Default Grid

However, I need a way to offset the Y position of every second column to make the end result look like this:

enter image description here

I'm aware that I could use multiple Grids to achieve this, but is there any way this can be done with a single Grid? Or even perhaps a different Control?

Thanks

Upvotes: 0

Views: 310

Answers (1)

Roland Deschain
Roland Deschain

Reputation: 2850

Make the grid rows only half the height, meaning double the rows: The use Grid.Row and Grid.Rowspan to create your layout. Just span every item over two rows and start every second column at Grid.Row = "1"

Upvotes: 1

Related Questions