TreeDataGridRowSelectionModel<TModel> Class
Definition
Implements row selection functionality for a Avalonia.Controls.TreeDataGrid control.
public class TreeDataGridRowSelectionModel<TModel>
Remarks
TreeDataGridRowSelectionModel manages row selection in a TreeDataGrid, supporting both single and multiple selection modes. It tracks selection using Avalonia.Controls.IndexPath instances that represent positions in the hierarchical structure.
Row selection supports the following user interactions:
- Clicking on rows to select them
- Using arrow keys to navigate between rows
- Using Shift key to select ranges of rows
- Expanding and collapsing hierarchical rows with arrow keys
- Type-to-select functionality for quickly finding rows
Constructors
| Name | Description |
|---|---|
| TreeDataGridRowSelectionModel<TModel> | No summary available. |
TreeDataGridRowSelectionModel<TModel> Constructor
public TreeDataGridRowSelectionModel<TModel>(Avalonia.Controls.TreeDataGridSource<TModel><TModel> source)
Parameters
source Avalonia.Controls.TreeDataGridSource<TModel><TModel>
Methods
| Name | Description |
|---|---|
| BatchUpdate | Creates a batch update operation that will defer selection change notifications until disposed. |
| BeginBatchUpdate | Begins a batch update of the selection. |
| Clear | Clears the selection. |
| Deselect | Deselects an item by its index in the source data. |
| EndBatchUpdate | Ends a batch update started by Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.BeginBatchUpdate. |
| IsSelected | Queries whether an item is currently selected. |
| Select | Selects an item by its index in the source data. |
| SelectAll | Selects all currently visible rows. |
| SelectRange | Selects an inclusive range of rows. |
BatchUpdate Method
Creates a batch update operation that will defer selection change notifications until disposed.
public Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<TModel>.BatchUpdateOperation<TModel><TModel> BatchUpdate()
Returns
Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<TModel>.BatchUpdateOperation<TModel><TModel>
A disposable object that, when disposed, will commit the selection changes and raise appropriate events.
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.TreeDataGridRowSelectionModel<T>.BeginBatchUpdate and Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.EndBatchUpdate.
BeginBatchUpdate Method
Begins a batch update of the selection.
public void BeginBatchUpdate()
Clear Method
Clears the selection.
public void Clear()
Deselect Method
Deselects an item by its index in the source data.
public void Deselect(Avalonia.Controls.IndexPath index)
Parameters
index Avalonia.Controls.IndexPath
The index into the source data.
EndBatchUpdate Method
Ends a batch update started by Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.BeginBatchUpdate.
public void EndBatchUpdate()
IsSelected Method
Queries whether an item is currently selected.
public bool IsSelected(Avalonia.Controls.IndexPath index)
Parameters
index Avalonia.Controls.IndexPath
The index of the item in the source data.
Returns
bool
True if the item is selected; otherwise false.
Select Method
Selects an item by its index in the source data.
public void Select(Avalonia.Controls.IndexPath index)
Parameters
index Avalonia.Controls.IndexPath
The index path of the item to select.
SelectAll Method
Selects all currently visible rows.
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; descendants of collapsed rows are not selected. This method does nothing when Avalonia.Controls.Selection.TreeDataGridSelectionModel.SingleSelect is true.
SelectRange Method
Selects an inclusive range of rows.
public void SelectRange(Avalonia.Controls.IndexPath start, Avalonia.Controls.IndexPath end)
Parameters
start Avalonia.Controls.IndexPath
The index of the row at which the range starts.
end Avalonia.Controls.IndexPath
The index of the row at which the range ends.
Remarks
The range is selected by iterating the currently visible rows between
start and end; any existing selection is
cleared first. This method does nothing when
Avalonia.Controls.Selection.TreeDataGridSelectionModel.SingleSelect is true.
Properties
| Name | Description |
|---|---|
| AnchorIndex | Gets or sets the anchor index. |
| Count | No summary available. |
| IsCellSelectionModel | Gets a value indicating whether this is a cell selection model. |
| RangeAnchorIndex | Gets or sets the range anchor index. |
| SelectedIndex | Gets or sets the selected index within the data. |
| SelectedIndexes | Gets the indexes of the selected items. |
| SelectedItem | Gets the currently selected item. |
| SelectedItems | Gets a collection containing all selected items. |
| SingleSelect | Gets or sets a value indicating whether only a single item can be selected at a time. |
| Source | Gets the data source for the selection model. |
AnchorIndex Property
Gets or sets the anchor index.
public Avalonia.Controls.IndexPath AnchorIndex { get; set; }
Remarks
The anchor index is the moving end of the selection: the item that keyboard navigation acts on. Pressing an arrow key navigates relative to this index, and a non-range selection updates it to the newly selected item. It is distinct from Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.RangeAnchorIndex, which is the fixed pivot that a range extends from.
For example, after selecting the range 1 to 3 (by clicking item 1 then Shift-clicking item 3, or by calling Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.SelectRange(Avalonia.Controls.IndexPath,Avalonia.Controls.IndexPath)), Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.RangeAnchorIndex is 1 (the pivot) while Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.AnchorIndex is 3 (the moving end). A subsequent Shift+Up then recomputes the range from the pivot 1 to the new end 2.
Count Property
public int Count { get; set; }
IsCellSelectionModel Property
Gets a value indicating whether this is a cell selection model.
public bool IsCellSelectionModel { get; set; }
RangeAnchorIndex Property
Gets or sets the range anchor index.
public Avalonia.Controls.IndexPath RangeAnchorIndex { get; set; }
Remarks
The range anchor index is the fixed pivot from which a range selection extends. It is
set when a fresh selection begins (for example when Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.SelectedIndex is set,
or to the anchor argument of Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.SelectRange(Avalonia.Controls.IndexPath,Avalonia.Controls.IndexPath)) and is preserved while
the range is extended, so that repeated Shift-click or Shift+arrow operations all
extend from the same point.
Unlike Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.AnchorIndex, it is not moved by a plain Avalonia.Controls.Selection.TreeDataGridRowSelectionModel<T>.Select(Avalonia.Controls.IndexPath) call or by extending a range; only by operations that start a new selection.
SelectedIndex Property
Gets or sets the selected index within the data.
public Avalonia.Controls.IndexPath SelectedIndex { get; set; }
SelectedIndexes Property
Gets the indexes of the selected items.
public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.IndexPath> SelectedIndexes { get; set; }
SelectedItem Property
Gets the currently selected item.
public TModel SelectedItem { get; set; }
Value
The selected item, or default(TModel) if no item is selected.
Remarks
When multiple items are selected, this property returns the first selected item.
SelectedItems Property
Gets a collection containing all selected items.
public System.Collections.Generic.IReadOnlyList<TModel> SelectedItems { get; set; }
Value
A read-only list of the selected items.
SingleSelect Property
Gets or sets a value indicating whether only a single item can be selected at a time.
public bool SingleSelect { get; set; }
Source Property
Gets the data source for the selection model.
public System.Collections.IEnumerable Source { get; set; }
Events
| Name | Description |
|---|---|
| SelectionChanged | Occurs when the selection changes. |
| IndexesChanged | Occurs when item indexes change due to insertions or removals in the data source. Inherited from TreeDataGridSelectionModel. |
| PropertyChanged | Inherited from TreeDataGridSelectionModel. |
| SourceReset | Occurs when the data source is reset. Inherited from TreeDataGridSelectionModel. |
SelectionChanged Event
Occurs when the selection changes.
public event EventHandler<Avalonia.Controls.Selection.TreeDataGridSelectionChangedEventArgs<T><TModel>> SelectionChanged
Remarks
This event provides strongly-typed access to the selection changes, including the items and index paths that were selected and deselected.