-
August 31st, 2009, 07:04 PM
#1
Object persistance using MVVM
This forum seems a bit quiet, if you cant answer my question, could you possibly point out a good forum that deals with the MVVM pattern?
MY QUESTION:
I am using WPF and the MVVM architecture. The problem is that I have a user control that edits the properties of an object. All the textbox's are bound to the relevant object in my model (through the viewmodel).
I want to know what to do when the user DOESNT save this information (they may navigate away, or press the cancel button). The problem is that if they edit the textbox, the model gets changed without the model being persisted to the database. So if they come back to view that object, it will appear as though the changes they made, last time when they were looking at the object, have changed the database. Of course they havent. I want the model to reflect the database. How is everyone solving this simple problem.
Does this make sense?
Its a very simple problem, but i dont know how everyone is getting around it.. what is the design pattern commonly used to solve this problem?
-
August 31st, 2009, 08:44 PM
#2
Re: Object persistance using MVVM
One approach is to make a copy of the VM when the control loads (and bind the control to the copy). If the data is saved update the real VM and persist to the db.
-
August 31st, 2009, 08:45 PM
#3
Re: Object persistance using MVVM
Oh, and welcome to the forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|