Skip to main content

ITreeDataGridSelectionInteraction Interface

Definition​

Assembly:Avalonia.Controls.TreeDataGrid
Package:Avalonia.Controls.TreeDataGrid
public interface ITreeDataGridSelectionInteraction

Remarks​

This interface is implemented by selection models to handle user interactions with the TreeDataGrid, such as keyboard navigation, pointer events, and selection state changes. It provides the connection between user input and the actual selection behavior.

This interface is experimental: it is exposed to allow custom selection models to be implemented, but it may be changed or removed in a future release.

Methods​

NameDescription
IsCellSelectedDetermines whether a specific cell is selected.
IsRowSelected (2 overloads)Determines whether a specific row model is selected.
OnKeyDownHandles the KeyDown event from the TreeDataGrid.
OnKeyUpHandles the KeyUp event from the TreeDataGrid.
OnPointerMovedHandles the PointerMoved event from the TreeDataGrid.
OnPointerPressedHandles the PointerPressed event from the TreeDataGrid.
OnPointerReleasedHandles the PointerReleased event from the TreeDataGrid.
OnPreviewKeyDownHandles the PreviewKeyDown event from the TreeDataGrid.
OnTextInputHandles the TextInput event from the TreeDataGrid.

IsCellSelected Method​

Determines whether a specific cell is selected.

public bool IsCellSelected(int columnIndex, int rowIndex)

Parameters​

columnIndex int

The index of the column.

rowIndex int

The index of the row.

Returns​

bool

true if the cell is selected; otherwise, false.

Remarks​

This method is used by the TreeDataGrid to determine whether to display a cell with the selected visual state.

IsRowSelected overloads​

IsRowSelected Method​

Determines whether a specific row model is selected.

public bool IsRowSelected(Avalonia.Controls.Models.ITreeDataGridRowModel rowModel)
Parameters​

rowModel Avalonia.Controls.Models.ITreeDataGridRowModel

The row model to check.

Returns​

bool

true if the row is selected; otherwise, false.

Remarks​

This method is used by the TreeDataGrid to determine whether to display a row with the selected visual state.

IsRowSelected Method​

Determines whether a specific row is selected.

public bool IsRowSelected(int rowIndex)
Parameters​

rowIndex int

The index of the row to check.

Returns​

bool

true if the row is selected; otherwise, false.

Remarks​

This method is used by the TreeDataGrid to determine whether to display a row with the selected visual state.

OnKeyDown Method​

Handles the KeyDown event from the TreeDataGrid.

public void OnKeyDown(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.KeyEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.KeyEventArgs

The event arguments.

Remarks​

This method handles key navigation and selection, such as using arrow keys to move the selection or using Space/Enter to select items.

OnKeyUp Method​

Handles the KeyUp event from the TreeDataGrid.

public void OnKeyUp(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.KeyEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.KeyEventArgs

The event arguments.

Remarks​

This method allows the selection model to respond to key releases.

OnPointerMoved Method​

Handles the PointerMoved event from the TreeDataGrid.

public void OnPointerMoved(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.PointerEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.PointerEventArgs

The event arguments.

Remarks​

This method can be used to handle behaviors like drag selection.

OnPointerPressed Method​

Handles the PointerPressed event from the TreeDataGrid.

public void OnPointerPressed(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.PointerPressedEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.PointerPressedEventArgs

The event arguments.

Remarks​

This method handles selection when the user presses a pointer (mouse, touch, etc.) on a row or cell. It typically manages behaviors like click-to-select and tracks the starting point for range selections with Shift key.

OnPointerReleased Method​

Handles the PointerReleased event from the TreeDataGrid.

public void OnPointerReleased(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.PointerReleasedEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.PointerReleasedEventArgs

The event arguments.

Remarks​

This method handles completing a selection when the user releases a pointer (mouse button, touch, etc.). It's particularly important for selection gestures that start with PointerPressed and complete with PointerReleased.

OnPreviewKeyDown Method​

Handles the PreviewKeyDown event from the TreeDataGrid.

public void OnPreviewKeyDown(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.KeyEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.KeyEventArgs

The event arguments.

Remarks​

This method is called in the tunneling phase of the event, allowing the selection model to handle key presses before they reach other controls.

OnTextInput Method​

Handles the TextInput event from the TreeDataGrid.

public void OnTextInput(Avalonia.Controls.TreeDataGrid sender, Avalonia.Input.TextInputEventArgs e)

Parameters​

sender Avalonia.Controls.TreeDataGrid

The TreeDataGrid that raised the event.

e Avalonia.Input.TextInputEventArgs

The event arguments.

Remarks​

This method allows the selection model to respond to text input, which can be used for features like type-to-select.

Events​

NameDescription
SelectionChangedOccurs when the selection in the TreeDataGrid changes.

SelectionChanged Event​

Occurs when the selection in the TreeDataGrid changes.

public event EventHandler SelectionChanged

Remarks​

This event is raised by the selection model when the selection changes, allowing the TreeDataGrid to update its visual representation accordingly.