tags:

views:

265

answers:

1

Hi,

I am learning MVVM using sample created by Josh Smith at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx I wanted to add a functionality of update in the existing code,

Like when user sees data on the Grid of 'All Customers' user can edit particular record by double clicking it, double click will open up new tab (same view/viewmodel that is used for new customer). I don't have any idea how to do it, do i have to call it through mainwindowviewmodel or there is some other way.

Thank You All and Happy Programming

GAurav Joshi

+1  A: 
Mark Seemann
Hi Mark, Thank You for your post and Sorry I am writing in comments, didn't found any other way on stackoverflow to reply. Do you think it is ok to declare 'workspace' static and creating new command in customerviewmodel it self which will create new workspace and add it to the mainwindowviewmdodel workspace. that way idon't have to implement isselected. Just want some expert inputs Thank YouGj
Gaurav
In general, I try to stay away from statics as much as possible, since it tends to hurt Testability, flexibility and just general OO-ness. The whole point of ViewModels is that they model Views. You can't have one Model per View if there are no instances of the Model. It may be the case that there is only one Workspace anyway, but just the same I'd say that using statics is to go against the whole philosophy behind MVVM. I know my reasoning sounds a bit vague, but those are just general considerations based on years of experience :)
Mark Seemann
Mark. The only Issue I see in your reply is that you recommend putting the IsSelected property in the Customer Model. I think it should go in the CustomerViewModel class because it is a GUI oriented property, and a Customer Model object really has no concept of what being selected means.
Tim Rupe
I just checked again, and that project does already have a IsSelected property for the CustomerViewModel class.
Tim Rupe
@Tim Rupe: You are absolutely right - my mistake. I'll edit my answer based on your observation. Thank you.
Mark Seemann
Mark: how would you create the new workspace for the item edited?
Eduardo Molteni
@Eduardo Molteni: Take a look a this SO answer: http://stackoverflow.com/questions/1023995/mvvm-and-commands-that-show-more-gui/1024011#1024011
Mark Seemann