Passing parameter/property to VM on Bootstrapper

Mar 4, 2011 at 3:20 PM
Edited Mar 4, 2011 at 3:23 PM


I'm working with some basics of Caliburn.Micro, and I have a simple application that binds correctly his View and ViewModel.

But the thing is, I need to pass an instance of an object Session to the ViewModel instance

I'm looking for some about passing parameters to the ViewModel (but not from the View), or assign a property to it, but have almost nothing until now

First try it's doing something on the Boostrapper of my app, get the instance of the ViewModel here and try to assign the property, but still don't have clear on what is the way to it

I think that would be something obviusly and common to do, but I don't found some similar case, or probably I don't understand totally the CMicro's reach at this point... Could something give me a light into this? 

Thanks for your time,


Mar 4, 2011 at 9:43 PM

It sounds like using an IoC container will help solve your problem. Have a look at the Game Library sample and the HelloScreens sample. Those are both a little more complicated architecturally and may give you some ideas.

Apr 6, 2011 at 2:22 PM

Thanks for your response,

I've seen that examples and search for some others, and I found a post explaining the work with parameters on the constructor with Caliburn.Micro.

It's on

It tells: "Basically when CM comes in to construct an instance of you VM for you, it also nicely ties into the IoC to supply all the constructor parameters that you need.  Well, as long as you have registered them in the boot strapper so that CM knows about them. "

With this paragraph I think that resolve what I was suppossing about the examples above.  But...

When I try to implement this, in first place with SimpleContainer, and later with Unity or CompositeContainer, the message that I get is only: "No parameterless constructor defined for this object".  Of course it is like that, it's what I need to do, and according the article it's possible... but doesn't work for me.

Any help?

Thanks for your time,