In Prism (CAL), how can I RegisterPresenterWithRegion instead of RegisterViewWithRegion

Posted by Edward Tanguay on Stack Overflow See other posts from Stack Overflow or by Edward Tanguay
Published on 2009-09-04T15:34:44Z Indexed on 2010/05/07 19:08 UTC
Read the original article Hit count: 300

I have a module in a Prism application and in its initialize method I want to register a presenter instead of a view with a region, i.e. I want to do this:

PSEUDO-CODE:

regionManager.RegisterPresenterWithRegion(
    	"MainRegion", typeof(Presenters.EditCustomerPresenter));

instead of loading a view like this:

regionManager.RegisterViewWithRegion(
    	"MainRegion", typeof(Views.EditCustomerView));

The presenter would of course bring along its own view and ultimately register this view in the region, but it would allow me to bind the presenter to the view in the presenter's constructor instead of binding the two together in XAML (which is more of a decoupled MVVM pattern which I want to avoid here).

How can I add a Presenter to a Region instead of a view?

namespace Client.Modules.CustomerModule
{
    [Module(ModuleName = "CustomerModule")]
    public class CustomerModule : IModule
    {
        private readonly IRegionManager regionManager;

        public CustomerModule(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
        }


        public void Initialize()
        {
            regionManager.RegisterViewWithRegion("MainRegion", typeof(Views.EditCustomerView));
        }
    }
}

© Stack Overflow or respective owner

Related posts about prism

Related posts about composite