There are two scenarios:
-
You select a row and press delete key to delete row.
-
You select a cell and when its text is highlighted you press delete key to delete text.
How do I distinguish between the two? in both cases I catch PreviewKeyPress and the Key is Delete Key, selected row is same.
For identifying the source of keypress, capture
e.OriginalSourcein thePreviewKeyPress(..)and check whether a cast toDataGridRoworDatagridCellis successful.DataGridhas theIsReadOnlyproperty.