UniformGrid Layout
Equal cells filled row by row, with the row and column counts derived when you leave them out.
Overview
UniformGrid divides itself into equally sized cells and drops the children into
them in order, left to right and then top to bottom. It is the right panel for a dashboard
of tiles, a button pad, or anything where the children have no individual size opinion.
"Equal" has to be exact in a terminal, where a cell is an integer and there is no such thing as a third of one. Ten columns of space across three columns of grid gives 4 / 3 / 3, not three lots of three with a cell quietly thrown away: the remainder is handed out one cell at a time to the leading columns, so the widths always add back up to the panel. When there are more columns than there are cells to give them, the trailing columns get zero and their children are skipped — the panel draws as much as fits instead of rounding everything to zero and drawing nothing.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Rows | int | 0 | Number of rows. 0 derives it from Columns and the number of non-collapsed children. |
| Columns | int | 0 | Number of columns. 0 derives it from Rows and the number of non-collapsed children. |
| Background | Color? | null | Inherited from Panel. |
With both left at 0 the panel picks the nearest square: Columns
becomes ceil(sqrt(n)) and Rows follows from it. Nine children give
a 3×3; five give three columns over two rows.
Key Concepts
- Children fill row by row, in declaration order
- Leftover cells go to the leading rows and columns, so the sizes always sum back to the panel
- Set one of
Rows/Columnsand the other is derived; set neither and the panel picks a near-square shape - Children beyond
Rows × Columnsare dropped rather than stacked on top of the last cell Visibility="Collapsed"occupies no cell at all — it is excluded from the derived shape and the children after it shift up;Hiddenkeeps its cell and paints as background