Skip to main content

TreeDataGridCellSelectionModel<TModel> Class

Definition​

Assembly:Avalonia.Controls.TreeDataGrid
Package:Avalonia.Controls.TreeDataGrid

Implements cell selection functionality for a Avalonia.Controls.TreeDataGrid control.

public class TreeDataGridCellSelectionModel<TModel>

Inheritance: object -> TreeDataGridSelectionModel -> TreeDataGridCellSelectionModel<TModel>

Remarks​

TreeDataGridCellSelectionModel manages cell selection in a TreeDataGrid, supporting both single and multiple selection modes.

Cell selection supports the following user interactions:

  • Clicking on cells to select them
  • Using arrow keys to navigate between cells
  • Using Shift key to select ranges of cells

Constructors​

NameDescription
TreeDataGridCellSelectionModel<TModel>No summary available.

TreeDataGridCellSelectionModel<TModel> Constructor​

public TreeDataGridCellSelectionModel<TModel>(Avalonia.Controls.TreeDataGridSource<TModel><TModel> source)

Parameters​

source Avalonia.Controls.TreeDataGridSource<TModel><TModel>

Methods​

NameDescription
BatchUpdateReturns a disposable that groups multiple selection operations into a single batch, raising only a single set of change events when disposed.
BeginBatchUpdateBegins a batch update of the selection.
ClearClears the selection.
EndBatchUpdateEnds a batch update started by Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.BeginBatchUpdate.
IsSelected (2 overloads)Checks whether the specified cell is selected.
SelectAllSelects all cells in the grid.
SetSelectedRangeSets the current selection to the specified range of cells.

BatchUpdate Method​

Returns a disposable that groups multiple selection operations into a single batch, raising only a single set of change events when disposed.

public Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<TModel>.BatchUpdateOperation<TModel><TModel> BatchUpdate()

Returns​

Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<TModel>.BatchUpdateOperation<TModel><TModel>

Remarks​

Use this method with a using statement to group multiple selection operations together and raise only a single set of change events when the batch is complete. This is equivalent to calling Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.BeginBatchUpdate and Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.EndBatchUpdate.

BeginBatchUpdate Method​

Begins a batch update of the selection.

public void BeginBatchUpdate()

Remarks​

During a batch update no changes to the selection will be reflected in the model's properties and no events will be raised until Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.EndBatchUpdate is called.

Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.BeginBatchUpdate may be called multiple times, even when a batch update is already in progress; each call must have a corresponding call to Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.EndBatchUpdate in order to finish the operation.

Clear Method​

Clears the selection.

public void Clear()

EndBatchUpdate Method​

Ends a batch update started by Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.BeginBatchUpdate.

public void EndBatchUpdate()

IsSelected overloads​

IsSelected Method​

Checks whether the specified cell is selected.

public bool IsSelected(Avalonia.Controls.CellIndex index)
Parameters​

index Avalonia.Controls.CellIndex

The index of the cell.

Returns​

bool

IsSelected Method​

Checks whether the specified cell is selected.

public bool IsSelected(int columnIndex, Avalonia.Controls.IndexPath rowIndex)
Parameters​

columnIndex int

The column index of the cell.

rowIndex Avalonia.Controls.IndexPath

The row index of the cell.

Returns​

bool

SelectAll Method​

Selects all cells in the grid.

public void SelectAll()

Remarks​

Only rows that are currently materialized in the source (i.e. visible, taking into account the expanded/collapsed state of parent rows) are selected. This method does nothing when Avalonia.Controls.Selection.TreeDataGridCellSelectionModel<T>.SingleSelect is true.

SetSelectedRange Method​

Sets the current selection to the specified range of cells.

public void SetSelectedRange(Avalonia.Controls.CellIndex start, int columnCount, int rowCount)

Parameters​

start Avalonia.Controls.CellIndex

The cell from which the selection should start.

columnCount int

The number of columns in the selection.

rowCount int

The number of rows in the selection.

Properties​

NameDescription
CountGets the number of cells currently selected.
IsCellSelectionModelGets a value indicating whether this is a cell selection model.
SelectedIndexGets or sets the index of the currently selected cell.
SelectedIndexesGets a read-only list of the indices of all selected cells.
SingleSelectGets or sets a value indicating whether only a single cell can be selected at a time.
SourceGets the data source for the selection model.

Count Property​

Gets the number of cells currently selected.

public int Count { get; set; }

IsCellSelectionModel Property​

Gets a value indicating whether this is a cell selection model.

public bool IsCellSelectionModel { get; set; }

SelectedIndex Property​

Gets or sets the index of the currently selected cell.

public Avalonia.Controls.CellIndex SelectedIndex { get; set; }

Remarks​

If multiple cells are selected, this property represents the anchor cell of the selection. Setting this property will select the cell at the specified index and deselect all other cells.

SelectedIndexes Property​

Gets a read-only list of the indices of all selected cells.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.CellIndex> SelectedIndexes { get; set; }

Value​

A read-only list of Avalonia.Controls.CellIndex objects representing the coordinates of all selected cells.

SingleSelect Property​

Gets or sets a value indicating whether only a single cell can be selected at a time.

public bool SingleSelect { get; set; }

Remarks​

When set to true, selecting a cell will deselect any previously selected cells. When set to false, additional cells can be selected by holding Shift.

Source Property​

Gets the data source for the selection model.

public System.Collections.IEnumerable Source { get; set; }

Events​

NameDescription
IndexesChangedOccurs when item indexes change due to insertions or removals in the data source. Inherited from TreeDataGridSelectionModel.
PropertyChangedInherited from TreeDataGridSelectionModel.
SelectionChangedOccurs when the cell selection changes.
SourceResetOccurs when the data source is reset. Inherited from TreeDataGridSelectionModel.

SelectionChanged Event​

Occurs when the cell selection changes.

public event EventHandler<Avalonia.Controls.Selection.TreeDataGridSelectionChangedEventArgs<T><TModel>> SelectionChanged

Remarks​

This event is raised when cells are selected or deselected, either through user interaction or programmatically.