Link to home
Start Free TrialLog in
Avatar of dineshwins
dineshwins

asked on

Object Cloning using MVVMLight

We want to create a copy of the object being edited before making any changes to the objects. We are using MVVMLight with WPF. Kindly suggest some approaches to implement object cloning using MVVMLight.
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

In your view model just make a backup of the object.

Dim backup as MyService.MyObject
Dim theObject as MyService.MyObject


Sub cmdEdit_Click
  backup = theobject
  edit = true
end sub

Sub RollBack
  theobject = backup
end sub
Avatar of dineshwins
dineshwins

ASKER

@ged325: I assume the above will create a shallow copy whereas I require the Deep Copy of the object being edited so that at any stage user can revert back to the original values.
then instead of backup use clone.

backup = theobject.Clone()

theobject = backup.Clone()

http://silverlightarvind.blogspot.com/2010/05/c-shallow-copy-vs-deep-copy.html

ASKER CERTIFIED SOLUTION
Avatar of dineshwins
dineshwins

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nobody was able to provide me with the required solution. I did my RnD & found a solution to the problem.