I have entities Profile and Contact. What I would like is to have a ProfileDetailView where you can edit the main entity (Profile) info, and on the
same view to have a gridview of Contacts with add/edit/delete functionality.
On ProfileListView, at editProfileButton_Click, I have the classic
which loads detailModel containing all related Contacts. However the next line (as provided by templates),
clears all the Contacts from the detailModel.
ProfileDetailViewModel detailModel = new ProfileDetailViewModel(model.SelectedProfile);
Contacts datagrid, binded to Model.Contacts on the ProfileDetailView is thus loaded empty. However if I click cancel, for a brief moment before the
window closes, Contacts appear in datagrid. I believe that is from after EndEdit/CancelEdit call. If I remove those, data is shown correctly.
Then in ProfileDetailView.xaml.cs at btnAddContact_Click in item.Closed callback I do
is null. This works ok.
This all leaves me a bit confused as I've been working on child CRUD functionality for a few days now and still haven't come up with anything usefull.
Am I doing it wrong? Is there a sample? I've read http://simplemvvmtoolkit.codeplex.com/discussions/268773 which deals with a similar problem, but
unfortunately haven't found it helpful.
Finally getting add/edit to work, I still have an issue with delete. Problem lies in not deleting a Contact from the database, but changing the model
so that Contact.SubjectID foreign key is set to NULL, which is not allowed, causing Save to fail due to database constraints.
So ... how does one go about deleting child entities of an object shown in detail view?
Thanks and keep up the good work!