I'm trying to build simplest CRUD application on Windows desktop. Decided to go with WPF over Windows Forms and Lightswitch.
Created database, then generated "Code first from database" with Entity Framework. Put datagrid with one table, set datasource. Run - it worked, I can Read.
Added a button, created Click handler with context.SaveChanges(); - ok, Update works.
Now, cannot get to Create part. Added
authorsDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
if (e.EditAction == DataGridEditAction.Commit)
{
var newAuthor = e.Row.Item as authors;
context.authors.Add(newAuthor);
context.SaveChanges();
}
}
and unfortunately e.Row.Item (or e.Row.DataContext) comes in empty. Where could be mistake?
WPF/WinForm CRUD tutorial links are welcome; been googling for days, haven't found a good one.