passing a model to vm

Dec 22, 2010 at 9:19 PM


can you show me an example for sending a model to vm through workspacedata

for example i have a Student (Model) object which i want to show in my view that i will load using the view and viewmodel resolution through creating a workspacedata object added to my Views collection ?

Dec 23, 2010 at 7:26 AM
Edited Dec 23, 2010 at 7:27 AM

If you look at the WPF demo that comes with CinchV2 you will see how to pass contextual data (Model in your case). Have a close look at MainWindowViewModel and also ImageLoaderView (code behind) and also ImageLoaderViewModel.

Its all about using WorkSpaceData to pass some context object to the View. The View MUST implement IWorkSpaceAware, then the ViewModel for the newly created View needs to use the ViewAwareStatusService and hook up listener for loaded, and in loaded can get contextual data that was passed to the View from original ViewModel that created WorkSpaceData.


Look at WPF demo its all in there.


And although not directly answering your query, see this forum, read it all :

Dec 24, 2010 at 4:13 AM

thanks sacha,

Wish you a happy X'Mas

Dec 24, 2010 at 7:05 AM

Thanks Wilzad.....Hey one thing that may be of interest, at some point over next week or 2, I will be writing another article that shows how to use CinchV2 with PRISM region support. It turns out to be very easy.

Dec 24, 2010 at 3:04 PM

I had been using prism for some time now, glad to know cinch is supporting prism too.

I am reading through your code now to see if i can implement something to use data annotations to validate model.

Dec 24, 2010 at 9:52 PM

As all the base classes are partial, it should be possible, but you will have to change some code around or add it.

Dec 25, 2010 at 5:09 AM

i did, its working now

Dec 26, 2010 at 7:39 AM