Class Grid
The Grid class represents an interactive grid that suppports cell display and selection/highlighting via mouse/keyboard/touch
Namespace: Maze.Maui.Controls.InteractiveGrid
Assembly: Maze.Maui.Controls.dll
Syntax
public class Grid : Grid
Constructors
Grid()
Constructor
Declaration
public Grid()
Fields
ContainerContentViewProperty
The container content view linked to the object
Declaration
public static readonly BindableProperty ContainerContentViewProperty
Field Value
| Type | Description |
|---|---|
| BindableProperty | Container content view |
ContainerScrollViewProperty
The container scroll view linked to the object
Declaration
public static readonly BindableProperty ContainerScrollViewProperty
Field Value
| Type | Description |
|---|---|
| BindableProperty | Container scroll view |
Properties
ActiveCell
The current active cell frame (if any)
Declaration
public CellFrame? ActiveCell { get; }
Property Value
| Type | Description |
|---|---|
| CellFrame | Active cell frame |
ActiveCellBackgroundColor
Active cell background color
Declaration
public Color ActiveCellBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Active cell background color |
AllColumnsSelected
Indicates whether the grid currently has all columns selected
Declaration
public bool AllColumnsSelected { get; }
Property Value
| Type | Description |
|---|---|
| bool | Boolean |
AllRowsSelected
Indicates whether the grid currently has all rows selected
Declaration
public bool AllRowsSelected { get; }
Property Value
| Type | Description |
|---|---|
| bool | Boolean |
AnchorCellBackgroundColor
Anchor cell background color
Declaration
public Color AnchorCellBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Anchor cell background color |
CellBackgroundColor
Cell background color
Declaration
public Color CellBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Cell background color |
CellBorderColor
Cell border color
Declaration
public Color CellBorderColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Cell border color |
CellHeight
Cell height (in DIPs)
Declaration
public double CellHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Cell height |
CellMargin
Cell margin (in DIPs)
Declaration
public double CellMargin { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Cell margin |
CellPadding
Cell padding (in DIPs)
Declaration
public double CellPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Cell padding |
CellWidth
Cell width (in DIPs)
Declaration
public double CellWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Cell width |
ColumnCount
Number of columns within the grid (excluding header columns)
Declaration
public int ColumnCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int | Number of columns |
ColumnHeaderHeight
Column header height (in DIPs)
Declaration
public double ColumnHeaderHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Column header height |
ColumnHeaderMargin
Column header margin (in DIPs)
Declaration
public double ColumnHeaderMargin { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Column header margin |
ColumnHeaderPadding
Column header padding (in DIPs)
Declaration
public double ColumnHeaderPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Column header padding |
ContainerContentView
The container content view linked to the object
Declaration
public ContentView ContainerContentView { get; set; }
Property Value
| Type | Description |
|---|---|
| ContentView | Container content view |
ContainerScrollView
The container scroll view linked to the object
Declaration
public ScrollView ContainerScrollView { get; set; }
Property Value
| Type | Description |
|---|---|
| ScrollView | Container scroll view |
CurrentSelection
The current selected cell range (if any)
Declaration
public CellRange? CurrentSelection { get; }
Property Value
| Type | Description |
|---|---|
| CellRange | Selected cell range |
HeaderActiveBackgroundColor
Header background color when active
Declaration
public Color HeaderActiveBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Header background color when active |
HeaderBackgroundColor
Header background color
Declaration
public Color HeaderBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Header background color |
HeaderBorderColor
Header border color
Declaration
public Color HeaderBorderColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Header border color |
HeaderSelectedBackgroundColor
Header background color when selected
Declaration
public Color HeaderSelectedBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Header background color when selected |
HeaderTextColor
Header text color
Declaration
public Color HeaderTextColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Header text color |
HighlightCellBackgroundColor
Cell background color when highlighted
Declaration
public Color HighlightCellBackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Cell background color when highlighted |
IsExtendedSelectionMode
Indicates whether the grid is currently in extended selection mode
Declaration
public bool IsExtendedSelectionMode { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | Boolean |
IsPanSupportEnabled
Indicates whether the grid has pan support enabled
Declaration
public bool IsPanSupportEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | Boolean |
RowCount
Number of rows within the grid (excluding header rows)
Declaration
public int RowCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int | Number of rows |
RowHeaderMargin
Row header margin (in DIPs)
Declaration
public double RowHeaderMargin { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Row header margin |
RowHeaderPadding
Row header padding (in DIPs)
Declaration
public double RowHeaderPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Row header padding |
RowHeaderWidth
Row header width (in DIPs)
Declaration
public double RowHeaderWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Row header width |
SelectionFrameBorderColor
Selection frame border color
Declaration
public Color SelectionFrameBorderColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | Selection frame border color |
SelectionFrameBorderGripDiameter
Selection frame border grip diameter (in DIPs)
Declaration
public double SelectionFrameBorderGripDiameter { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Selection frame border grip diameter |
SelectionFrameBorderWidth
Selection frame border width
Declaration
public double SelectionFrameBorderWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Selection frame border width |
Methods
ActivateCell(CellPoint, bool)
Activates a given cell based on a point definition
Declaration
public bool ActivateCell(CellPoint point, bool maintainSelection)
Parameters
| Type | Name | Description |
|---|---|---|
| CellPoint | point | Cell point |
| bool | maintainSelection | Maintain current selection? |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
ActivateCell(int, int, bool)
Activates a given cell based on a display row and column where (1,1) is the top-left cell
Declaration
public bool ActivateCell(int displayRow, int displayColumn, bool maintainSelection)
Parameters
| Type | Name | Description |
|---|---|---|
| int | displayRow | Display row |
| int | displayColumn | Display column |
| bool | maintainSelection | Maintain current selection? |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
CancelExtendedSelection()
Cancels extended selection mode
Declaration
public void CancelExtendedSelection()
CreateCellContent(CellFrame, int, int, bool)
Creates cell content, where (0,0) corresponds to (1,1) in display terms
Declaration
public virtual ContentView CreateCellContent(CellFrame frame, int row, int column, bool gridInitializing)
Parameters
| Type | Name | Description |
|---|---|---|
| CellFrame | frame | Container frame |
| int | row | Row index |
| int | column | Column index |
| bool | gridInitializing | Grid is initializing? |
Returns
| Type | Description |
|---|---|
| ContentView | Cell content view |
DeleteColumns(int, int)
Deletes the given range of columns
Declaration
public bool DeleteColumns(int startDisplayColumn, int endDisplayColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startDisplayColumn | Start display column |
| int | endDisplayColumn | End display column |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
DeleteRows(int, int)
Deletes the given range of rows
Declaration
public bool DeleteRows(int startDisplayRow, int endDisplayRow)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startDisplayRow | Start display row |
| int | endDisplayRow | End display row |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
DeleteSelectedColumns()
Deletes the selected columns, providing all rows are selected and there is more than one column
Declaration
public bool DeleteSelectedColumns()
Returns
| Type | Description |
|---|---|
| bool | Boolean |
DeleteSelectedRows()
Deletes the selected rows, providing all columns are selected and there is more than one row
Declaration
public bool DeleteSelectedRows()
Returns
| Type | Description |
|---|---|
| bool | Boolean |
EnableExtendedSelection()
Enables extended selection mode
Declaration
public void EnableExtendedSelection()
FindCellColumnAtXOffset(int, XOffsetType, double)
Locates the cell column number offset from a starting column
Declaration
public int FindCellColumnAtXOffset(int startColumn, Grid.XOffsetType type, double offset)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startColumn | Start column against which offset is measured |
| Grid.XOffsetType | type | Offset type |
| double | offset | Offset amount |
Returns
| Type | Description |
|---|---|
| int | Column number |
FindCellRowAtYOffset(int, YOffsetType, double)
Locates the cell row number offset from a starting row
Declaration
public int FindCellRowAtYOffset(int startRow, Grid.YOffsetType type, double offset)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startRow | Start row against which offset is measured |
| Grid.YOffsetType | type | Offset type |
| double | offset | Offset amount |
Returns
| Type | Description |
|---|---|
| int | Row number |
GetAsyncKeyState(int)
Determines the current press state of a given key
Declaration
public static extern short GetAsyncKeyState(int vKey)
Parameters
| Type | Name | Description |
|---|---|---|
| int | vKey |
Returns
| Type | Description |
|---|---|
| short | Key state |
GetCell(int, int)
Gets the cell associated with a given row and column
Declaration
protected Border? GetCell(int row, int column)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row |
| int | column | Column |
Returns
| Type | Description |
|---|---|
| Border | Cell border |
GetCellsHeight(CellRange)
Gets the total display height associated with a given cell range
Declaration
public double GetCellsHeight(CellRange range)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | range | Cell range |
Returns
| Type | Description |
|---|---|
| double | Total display height |
GetCellsWidth(CellRange)
Gets the total display width associated with a given cell range
Declaration
public double GetCellsWidth(CellRange range)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | range | Cell range |
Returns
| Type | Description |
|---|---|
| double | Total display width |
GetColumnWidth(int)
Gets the display width associated with a given column
Declaration
public double GetColumnWidth(int column)
Parameters
| Type | Name | Description |
|---|---|---|
| int | column | Column |
Returns
| Type | Description |
|---|---|
| double | Display width |
GetHeaderCellContent(HeaderType, int)
Gets the content for a header cell
Declaration
public virtual View GetHeaderCellContent(HeaderType type, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| HeaderType | type | Header cell type |
| int | index | Header cell index |
Returns
| Type | Description |
|---|---|
| View | View containing content |
GetRowHeight(int)
Gets the display height associated with a given row
Declaration
public double GetRowHeight(int row)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row |
Returns
| Type | Description |
|---|---|
| double | Display height |
GetSelectionState()
Gets the current selection state
Declaration
public SelectionState GetSelectionState()
Returns
| Type | Description |
|---|---|
| SelectionState | Selection state |
InitializeContent()
Initializes the grid's content based on the number of rows and columns that have been specified. Will call GetHeaderCellContent(HeaderType, int) and CreateCellContent(CellFrame, int, int, bool) to initialize individual header and cell content. These methods should be overridden in your derived class. If this is not done, numbered headers will be inserted and each cell will be initialized with an empty label.
Declaration
public void InitializeContent()
InsertColumns(int, int)
Inserts columns before the given range of columns
Declaration
public bool InsertColumns(int startDisplayColumn, int endDisplayColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startDisplayColumn | Start display column |
| int | endDisplayColumn | End display column |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
InsertRows(int, int)
Inserts rows before the given range of rows
Declaration
public bool InsertRows(int startDisplayRow, int endDisplayRow)
Parameters
| Type | Name | Description |
|---|---|---|
| int | startDisplayRow | Start display row |
| int | endDisplayRow | End display row |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
InsertSelectedColumns()
Inserts columns before the selection, providing all rows are selected
Declaration
public bool InsertSelectedColumns()
Returns
| Type | Description |
|---|---|
| bool | Boolean |
InsertSelectedRows()
Inserts rows before the selection, providing all columns are selected
Declaration
public bool InsertSelectedRows()
Returns
| Type | Description |
|---|---|
| bool | Boolean |
IsValidDisplayColumn(int)
Tests whether a given display column is valid
Declaration
public bool IsValidDisplayColumn(int displayColumn)
Parameters
| Type | Name | Description |
|---|---|---|
| int | displayColumn | Display column |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
IsValidDisplayRow(int)
Tests whether a given display row is valid
Declaration
public bool IsValidDisplayRow(int displayRow)
Parameters
| Type | Name | Description |
|---|---|---|
| int | displayRow | Display row |
Returns
| Type | Description |
|---|---|
| bool | Boolean |
OnCellDoubleTapped(CellFrame, bool)
Handles the cell double-tapped event
Declaration
public virtual void OnCellDoubleTapped(CellFrame cellFrame, bool triggerEvents)
Parameters
| Type | Name | Description |
|---|---|---|
| CellFrame | cellFrame | Cell frame that was double-tapped |
| bool | triggerEvents | Flag indicating whether to trigger further events |
OnCellTapped(CellFrame, bool)
Handles the cell tapped event
Declaration
public virtual void OnCellTapped(CellFrame cellFrame, bool triggerEvents)
Parameters
| Type | Name | Description |
|---|---|---|
| CellFrame | cellFrame | Cell frame that was tapped |
| bool | triggerEvents | Flag indicating whether to trigger further events |
OnProcessKeyDown(KeyState, Key, bool)
Handles the key down event
Declaration
public virtual void OnProcessKeyDown(KeyState state, Key key, bool triggerEvents)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyState | state | Key state |
| Key | key | Key pressed |
| bool | triggerEvents | Flag indicating whether to trigger further events |
OnSelectionChanged()
Overrideable handler for selection changed event
Declaration
public virtual void OnSelectionChanged()
ResetSelection(CellRange)
Resets the selection to the given selection
Declaration
public void ResetSelection(CellRange newSelection)
Parameters
| Type | Name | Description |
|---|---|---|
| CellRange | newSelection | New selection |
RestoreSelectionState(SelectionState, bool, bool)
Restores the selection to the given selection state
Declaration
public void RestoreSelectionState(SelectionState selectionState, bool retainAnchorCell, bool show)
Parameters
| Type | Name | Description |
|---|---|---|
| SelectionState | selectionState | Selection state |
| bool | retainAnchorCell | Reset anchor cell to that defined in the selection state? |
| bool | show | Show the selection frame? |
SetCellContent(CellFrame?, ContentView)
Sets cell content within a given cell frame
Declaration
public void SetCellContent(CellFrame? cellFrame, ContentView contentView)
Parameters
| Type | Name | Description |
|---|---|---|
| CellFrame | cellFrame | Cell frame |
| ContentView | contentView | Content to attach to cell |
SetCellContent(int, int, ContentView)
Sets cell content at a given location, where (0,0) corresponds to (1,1) in display terms
Declaration
public CellFrame? SetCellContent(int row, int column, ContentView contentView)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | Row index |
| int | column | Column index |
| ContentView | contentView | Content to attach to cell |
Returns
| Type | Description |
|---|---|
| CellFrame | Cell frame |