ViewModelBase.DoCancel()

ViewModelBase.DoCancel()

Old forum URL: forums.lhotka.net/forums/t/9472.aspx


t.kehl posted on Saturday, September 04, 2010

Hi.

I have seen, that DoCancel() of ViewModelBase calls

          undo.CancelEdit();
          undo.BeginEdit();

I ask me, why is DoCancel() calling Beginedit()? - I run in the fallowing Problem:

I open a EditableRoot-Object vor Editing. There is calling a BeginEdit(). Now, I open a Child-object of the Root-Object for Editing. There is now a BeginEdit on the Child. Now, I cancel the ChildEdit. DoCancel() now calls CancelEdit() and BeginEdit(). When I save now the root-object, I run into a EditLevel-Mismatch. The reason about this is the BeginEdit()-call of DoCancel(). I ask me now, why is DoCancel() calling also BeginEdit() and what I am doing wrong.

Thanks for your help.

Best Regards, Thomas

ajj3085 replied on Saturday, September 04, 2010

If it didn't, the user would then make some changes and hit cancel again, and nothing would happen.

For your child, I think in it's ViewModel class you would set ManageObjectLifetime to false to disable that behavior since it's covered by the parent.

t.kehl replied on Sunday, September 05, 2010

Hi Andy

Thank you for your reply. I have solved my problem now with setting ManageObjectLifetime to false in the "Child-VM".

Thomas

Copyright (c) Marimer LLC