#404 – A Grid Hosts Child Controls in Rows and Columns

A Grid is a layout container that positions its child elements into a series of rows and columns.  You specify the number of rows and columns, along with information about their size, in the Grid tag.  You then specify which row and column each control is located in using the Grid.Row and Grid.Column attached properties.

Rows are numbered top to bottom, starting at 0.  Columns are numbered left to right, starting at 0.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Label Grid.Row="0" Grid.Column="0"
               Content="Upper left"/>
        <Label Grid.Row="0" Grid.Column="1"
               Content="Upper right"/>
        <Label Grid.Row="1" Grid.Column="0"
               Content="Lower left"/>
        <Label Grid.Row="1" Grid.Column="1"
               Content="Lower right"/>
    </Grid>

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

3 Responses to #404 – A Grid Hosts Child Controls in Rows and Columns

  1. Pingback: Dew Drop – October 10, 2011 | Alvin Ashcraft's Morning Dew

  2. Pingback: #405 – Default Values for Grid.Row and Grid.Column Properties « 2,000 Things You Should Know About WPF

  3. Pingback: #578 – Grid Row and Column Size Use GridLength Object « 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: