#405 – Default Values for Grid.Row and Grid.Column Properties

You normally specify values for the Grid.Row and Grid.Column properties for each child element of a grid, indicating the cell in the grid where you’d like the child element positioned.

If you do not specify a value for either the Grid.Row or the Grid.Column properties, a value of 0 will be used for that property.  This places the element into the first row and/or first column, respectively.

In the example below, we’ve created a grid that has two rows and two columns.  We’ve mistakenly left off the Grid.Row and Grid.Column properties for the two child elements and so they have both been placed into the first row and first column.

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

        <Button Content="Push Me" Width="100" />
        <Label Content="Oops I'm in the same cell with a button !" />
    </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.

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: