I currently have a fairly straight forward app, my first attempt at MVVM using Josh Smiths classes, and have been looking at moving it over to Prism v4 using Unity. However I seem to have gotten confused about how to actually pass my model data to the relevant view models when they are separated in different modules.
The app itself has a collection of Document objects each containing a ref to a 3rd party video API instance and a bunch of meta data to describe and annotate the video.
I have written the video handling elements into a separate module that expects its data from an IVideoService. Similarly the documents will be provided, in a different module, by an IDocumentservice that will return the collection of docs, selected doc, etc.
I reference an instance of the IDocumentService in Unity so it can be resolved by any module. However I don’t see how I extract the relevant IVideoService for display when the document being viewed is changed. I don’t want to include any dependencies of the document module in the video module if possible so I assume I just register an instance of IVideoService and post some refresh event.. so the videomodule’s views update.
However that solution wouldn’t work if I had the capability to display two or more docs simultaneously.
In my previous non prism app my viewmodels had a hierarchy that mirrored the model hierarchy and everything was done using binding and datatemplates.
This doesn’t seem to be the way to do it in prism with each module initializing itself and declaring where it should appear. Looking at the various demo apps and code hasn’t cleared this up so I suspect there is something fundamental I’m misunderstanding.
Any enlightenment appreciated!
Regards
What about raising an event when the document being viewed gets changed? The event could pass the relevant IVideoService as part of the event arguments.