The Grid Panel

The Grid is one of the easiest panels to understand in WPF. It allows creating tables, with rows and columns. In this way you can define cells and each cell can contain a control or another panel storing nested controls. The Grid is versatile in that you can just divide it into rows or into columns or both. The following code defines a Grid that is divided into two rows and two columns:

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

RowDefinitions is a collection of RowDefinition objects, and the same is true for ColumnDefinitions and ColumnDefinition ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.