Color legend plain property dependency property method
Lays its items out in columns and rows. Each column and row is fixed, fitted to its content, or a share of the space left.
Grid derives from BaseElement and has its members too. The layout page shows it in context, with code and screenshots.
Names are colored by what they are: a plain property, a method, an event or a dependency property, which a style, a binding or an animation can set.
Properties
ColumnsCount 🠆
int · Read-only. The number of column definitions.
LayoutColor 🠆
Color · The color of the lines ShowLayout draws; the fill is this color with every channel divided by 5. Red unless set (DefaultSettings.DefaultGridLayoutColor, read when the grid is created).
RowsCount 🠆
int · Read-only. The number of row definitions.
ShowLayout 🠆
bool · Draws the grid’s outline, a line at the end of every column and row, and fills each of them with a dim shade of LayoutColor. A debugging aid, off by default.
Methods
Grid() 🠆
Grid(string name = null) · Creates a grid without definitions. The name is used by GetElementByName.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The element’s Name, which GetElementByName finds it by. Default: null. |
AddColumnDefinition() 🠆
AddColumnDefinition(int desiredSize) · Adds a column of a fixed width in units (at least 1).
| Parameter | Type | Description |
|---|---|---|
desiredSize |
int |
The column’s width, in units. |
AddColumnDefinition() · Adds an auto column, as wide as the widest content of its cells.
AddColumnDefinition(float proportion) · Adds a proportional column, a share of the width left. Negative values count as 0.
| Parameter | Type | Description |
|---|---|---|
proportion |
float |
The column’s share of the width the fixed and auto-sized columns leave, relative to the other proportional columns (two columns of 1.0f take half each). |
AddItem() 🠆
AddItem(BaseElement item) · Puts the item in the cell its GridColumn, GridRow and spans name, making the cell if needed. Ignored when the column or row doesn’t exist.
| Parameter | Type | Description |
|---|---|---|
item |
BaseElement |
The element to add. |
AddItemAt() 🠆
AddItemAt(BaseElement item, int index) · Does nothing: a grid places items by column and row. Use AddItem.
| Parameter | Type | Description |
|---|---|---|
item |
BaseElement |
The element to insert. |
index |
int |
The position to insert it at: 0 for the first, the number of items for the end. |
AddRowDefinition() 🠆
AddRowDefinition(int desiredSize) · Adds a row of a fixed height in units (at least 1).
| Parameter | Type | Description |
|---|---|---|
desiredSize |
int |
The row’s height, in units. |
AddRowDefinition() · Adds an auto row, as tall as the tallest content of its cells.
AddRowDefinition(float proportion) · Adds a proportional row, a share of the height left. Negative values count as 0.
| Parameter | Type | Description |
|---|---|---|
proportion |
float |
The row’s share of the height the fixed and auto-sized rows leave, relative to the other proportional rows (two rows of 1.0f take half each). |
Clear() 🠆
Clear() · Removes every definition and every item. The items are detached, not disposed, so they can be added again.
ClearItems() 🠆
ClearItems() · Removes every item and the emptied cells. The items are detached, not disposed; the definitions stay.
Draw() 🠆
Draw() · Draws the grid, with the ShowLayout lines under its items. The UI calls it; you don’t.
RemoveItem() 🠆
RemoveItem(BaseElement item) · Takes the item out of its cell. It is detached, not disposed.
| Parameter | Type | Description |
|---|---|---|
item |
BaseElement |
The element to take out. |
RemoveItemAt() 🠆
RemoveItemAt(int index) · Removes an item by its index in the items of all cells, cell by cell.
| Parameter | Type | Description |
|---|---|---|
index |
int |
The index of the item to take out. |
RemoveItemsRangeAt() 🠆
RemoveItemsRangeAt(int index, int count) · Removes count items from the index on, counted as in RemoveItemAt.
| Parameter | Type | Description |
|---|---|---|
index |
int |
The index of the first item to take out. |
count |
int |
The number of items to take out. |
TryGetCell() 🠆
TryGetCell(int column, int row, int columnSpan = 1, int rowSpan = 1) · Returns the cell at that place with those spans, or null when there is none (no item uses it) or the place is outside the grid. Spans are cut to the grid as AddItem cuts them.
| Parameter | Type | Description |
|---|---|---|
column |
int |
The index of the cell’s first column. |
row |
int |
The index of the cell’s first row. |
columnSpan |
int |
The number of columns the cell spans. Default: 1. |
rowSpan |
int |
The number of rows the cell spans. Default: 1. |