I put together a small app based on the sample using an EntityQueryPagedCollectionView. It all works fine. Now, I would like to add an item to the list.
I use EntityQueryPagedCollectionView.Add() to add the item to the list, and it does add it to the list correctly. And I can also save it correctly. However, after the item is added, the list then locks up. It can no longer be paged, nor sorted, nor can more than one item be added. Any idea what is going on with this?
The code looks like this:
public void LoadContacts()
{
var query = _mgr.ContactEntities;
this.Contacts = new EntityQueryPagedCollectionView(
query,
this.PageSize,
this.PageSize,
true,
false
);
this.Contacts.SortDescriptions.Add(new SortDescription("Last", ListSortDirection.Descending));
this.Contacts.Refresh();
}
internal void AddContact()
{
this.Contacts.AddNew();
}
internal void SaveContact()
{
EntitySaveOperation op = this._mgr.SaveChangesAsync();
op.Completed += new EventHandler<EntitySavedEventArgs>(op_Completed);
}
void op_Completed(object sender, EntitySavedEventArgs e)
{
EntitySaveOperation op = sender as EntitySaveOperation;
if (op.HasError)
{
MessageBox.Show(op.Error.Message);
}
this.Contacts.Refresh();
}