Tesserae

GridPicker

Description

The GridPicker component creates an interactive grid of buttons, where each cell can have multiple states. It is used for building grid-based state selectors and pickers, such as scheduling interfaces or game boards. The component is part of the Tesserae UI Components group and leverages a fluent interface to configure button appearance and behavior based on the state.

Usage

Create a GridPicker instance by providing arrays of column and row names, the number of states each cell can have, an initial state for every cell, and a function to format each button based on its state. Optionally, you can provide custom column sizes and row heights.

Below is a simple usage example:

Methods

GetState()

  • Description: Retrieves the current state of all grid cells.
  • Return Type: int[][] – A two-dimensional array where each element represents the state of a corresponding grid cell.
  • Usage Example:

SetState(int[][] state)

  • Parameters:
    • state: A two-dimensional integer array representing the new state for all cells.
  • Description: Updates the grid with new states and refreshes the UI accordingly.
  • Return Type: GridPicker – Returns the current instance for chaining.
  • Usage Example:

OnChange(ComponentEventHandler<GridPicker, Event> onChange)

  • Parameters:
    • onChange: A callback that is invoked when any cell state changes.
  • Description: Registers an event handler for change events occurring in the grid.
  • Return Type: GridPicker – Returns the current instance for chaining.
  • Usage Example:

Properties

IsDragging

  • Type: bool (read-only)
  • Description: Indicates whether a drag operation is currently in progress on the grid. When true, a batch update is in progress for a group of cells.

Samples

Basic GridPicker Example

The following sample demonstrates how to instantiate a simple GridPicker with two states. Each cell displays different text based on its current state.

Advanced GridPicker for Hourly Schedule

This sample shows how to create an hourly schedule picker by dynamically generating column headers for each hour of the day.

See also

  • Button – Often used in combination with GridPicker for interactive elements.
  • TextBlock – Useful for creating header or descriptive text in grid layouts.
© 2026 Tesserae. All rights reserved.