Description of application structure:
Language is C# with WPF and MVVM pattern. View is basically a DataGrid for displaying some DataTable values (through ViewModel). User is allowed to add, edit and delete rows from the grid. Some value restrictions apply (no nulls, only numeric, etc...) due to database from where values are retrieved and later inserted back.
Data modifications can be made directly to DataGrid but there is also a separate dialog for editing and adding new rows. A delete button works in a way that ViewModel finds selected DataGrid rows from DataTable, deletes them and changes are updated automatically to DataGrid as they should.
Problem:
So I'm having this problem where user attempts to insert invalid data to DataGrid and red exclamation mark appears to indicate that there is a problem with inserted data (validation error I guess?). If at this point user wishes to start over and selects invalid row for deletion, he is unable to delete that row as it does not exist in the model but only in DataGrid. Attempting to delete invalid DataGridRow directly from DataGrid throws an exception stating that DataGrid is bound to a Model and any modifications should be made there.
Finally question:
How to delete invalid DataGridRow which is not present in model?