How to register view/viewmodel in castle.windsor for use in prism navigation

Topics: Prism v4 - WPF 4
Nov 19, 2012 at 2:39 PM

This question was originally posted in this forum:

I am using Prism 4.1 and castle.windsor 3.1 in a WPF application. I'd like to use the Prism "view based" navigation framework. However, to do so, I must register my view with castle "as object." I have yet to find a way to do this so that the prism navigation framework can resolve the view when I call RegionManager.RequestNavigate. I currently register all views and viewmodels via convention. Any insight and especially, example registration code appreciated.

Nov 19, 2012 at 2:43 PM


Based on my understanding a possible approach to register your views in Windsor against the Object type could be for example like this:

.ImplementedBy(typeof(yourView)).Named("yourView").LifeStyle.Singleton); //The defined LifeStyle will deppend on your requirements

For more information about the different registration methods used by Windsor you could check the following resource:

On the other hand, take into account that the Prism library accesses the container through the IServiceLocator interface, hence if you want to use Prism with a container other than Unity or MEF in your application you will need to write a Service Locator adapter for your container and also need to write a container-specific bootstrapper class. This is mentioned in the Extending Prism Chapter of the Prism documentation.

If you need further assistance please let us know,

Agustin Adami