The grid lays out the content elements in the form of a grid, with the following characteristics:
- Can define any number of rows and columns, very flexible;
- The height of the row and the width of the column can be precisely set using absolute values, relative proportions, or automatic adjustments, and the maximum and minimum values can be set;
- Internal elements can set their own rows and columns, you can also set their own vertical span of several lines, across several columns horizontally;
- You can set the alignment direction of the children element.
Grid usage scenarios are:
- Large frame design of UI layout;
- A large number of UI elements that require rows or columns to align;
- When the overall UI size changes, the element needs to maintain the inherent height and width ratio;
- There may be large changes or extensions to the UI later.
Define Grid
the grid has ColumnDefinitions and rowdefinitions two attributes to define columns and rows, with the following code:
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> < rowdefinition/> <RowDefinition/> </Grid.RowDefinitions> </Grid>
View Code
It can also be added dynamically by code, as follows:
This. MYGRID.ROWDEFINITIONS.ADD (New RowDefinition ()); MYGRID.COLUMNDEFINITIONS.ADD (New ColumnDefinition ());
View Code
WPD layout elements