I have a DataGrid bound to a LINQ-TO-SQL table object: dataGrid.ItemsSource = myDataContext.MyItems;
This lets the user edit and insert database items without me having to implement a single line of code.
Great! BUT: I can't figure out how to insert new items programmatically. The DataGrid doesn't update when i add items to the table (myDataContext.MyItems.InsertOnSubmit(newItem)).
Of course i could copy the whole table to an observable collection, but keeping this in sync with the database sounds like a tedious job. Any better suggestions?
It would be ok for me to just fill text data into the last ("empty") row of the grid and let the user trigger the insert event (when the row loses focus).