Convention Based Model to ViewModel conversion injection.

Topics: Bootstrappers & IoC, Conventions, Extensibility, UI Architecture
Nov 22, 2012 at 5:35 AM

Hi there, short time fan, first time poster!

I'm getting started using an architecture utlising Caliburn Micro and MEF.

Where I am at, is how to deal with collections of model objects and\or how to wrap them in ViewModels. Either I'm missing the point entirely or this seems like a nasty operation.

The conundrum I currently have is that on a Main View Model, I have a list of <BaseClass> model objects, each of which may have a different ViewModel and View. The ViewModel is of type I<ViewModel> which is an import from MEF (and extensability point).

I like the idea explorered here:

But I can't quite work out how I can get this functionality to work in Caliburn Micro.

What I'd like to end up with is a convention based conversion that would take my model object and (using reflection) find a view model that I can inject this model object into, then return an instance of the viewmodel in place of the model object, then obviously resolve the view normally.

Any pointers you could give to acheive this goal, and or tell me if I'm barking up the wrong tree entirely.