I want it to only be possible to select one cell in a DataGrid. With multi select disabled, you can still select a range of cells, but I want it to only allow a single-cell selection. Is there any way to do this through the properties? Or will I have to intercept the selection and filter out everything but one cell?
The DataGrid
has a SelectionUnit
property of type DataGridSelectionUnit
, in conjunction with SelectionMode
:
The SelectionMode and SelectionUnit properties together define the selection behavior for the DataGrid.
Try setting SelectionUnit
to Cell
. This will work with both SelectionMode
values:
If the selection mode is Extended, the user can select multiple items where the item type is defined by the SelectionUnit property. If the selection mode is Single, the user can only select single items.
To select a single cell, use SelectionMode
of Single
and SelectionUnit
of Cell
:
The SelectionMode and SelectionUnit properties together determine how users can select items in a DataGrid. For example, if the SelectionMode is Single and the SelectionUnit is Cell, the user can select only one cell at a time in the DataGrid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With