Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
435
Selection lost when a cell changes to edit mode
posted

I have a behavior that changes cells in a column to edit mode when it becomes active.

If I am using the mouse to drag a selection of cells, as soon as I enter a cell that changes to edit mode, all the selection is lost.

Is there a way to maintain selection of all cells (including the cell that just changed to edit mode) when a cell changes to edit mode?

Parents
No Data
Reply
  • 34510
    Offline posted

    Hi rbccm,

    Yes it is possible to maintain selection while a cell is in edit mode.  However, you have to manually reselect the cell after edit mode as started.  The expected behavior of the grid is that when edit mode is started, selection is cleared.  You can change this by handling the EditModeStarting event on the XamDataGrid and resetting the Cell.IsSelected property on the previously selected cells.  This will mean that you need to keep track of what cells were selected.  Take a look at my attached sample.  When you hold down the Ctrl key, it will allow you to drag select cells.  You'll see that the currently activated cell enters edit mode, but the cell selection has not been lost.

    DataGridSelectionBehavior.zip
Children