Grid
The Grid
control is useful for arranging child controls in columns and rows. You can define absolute, proportional, and
autosized row and column geometries for the Grid
.
Each child control in the Grid
can be positioned in a Grid
cell using column and row coordinates. These are
zero-based, and both have a zero default.
If you position multiple child controls in the same cell, they will be drawn in that cell in the sequence they appear
in the XAML. This is another strategy to implement layer stacking besides Panel
.
If you omit column and row coordinates for the child controls of a Grid
, they will all be drawn in the top left
corner (column=0, row=0).
It is also possible to make a child control span more than one cell in either rows or columns, or both.
Useful Properties
You will probably use these properties most often:
Property | Description |
---|---|
ColumnDefinitions | Size definitions describing the widths of columns in the Grid . |
RowDefinitions | Size definitions describing the heights of rows in the Grid . |
ShowGridLines | Shows the gridlines between cells (as dashed lines). |
Grid.Column | Lays out the control into the specified zero-based column. |
Grid.Row | Lays out the control into the specified zero-based row. |
Grid.ColumnSpan | Spans the control across 1 or more columns. |
Grid.RowSpan | Spans the control across 1 or more rows. |
Grid.IsSharedSizeScope | Defines the control as the containing scope for a SharedSizeGroup |