Prism4 in Windows Forms environment

Topics: Prism v4 - WPF 4
Sep 13, 2011 at 1:23 PM
Hi, i have an existing WindowsForms application, and now i want to host some prism modules in it. The visual part should work with ElementHost, but what about the bootstrapper? Greets, **Jürgen**
Sep 13, 2011 at 10:01 PM


An approach to create and run a Bootstrapper in a windows forms application could be to use the following code in your Bootstrapper:

        private ElementHost host;

        public WindowsFormsBootstrapper(ElementHost host)
            : base()
   = host;

        protected override void InitializeShell()
   = (this.Shell as Shell);

Where host is the ElementHost control that will host your Shell, and in the code-behind of you windows form window’s constructor add:


        private ElementHost host;

        private static WindowsFormsBootstrapper bootstrapper;

        public WinFormsWindow()

 if (host != null) { bootstrapper = new WindowsFormsBootstrapper(host); bootstrapper.Run(); } }

However, there is a known issue in the Prism library where if the host application is not a WPF Application, the RegionManager does not register the views.

To prevent this for happening you need to change the code of the IsInDesignMode method of the RegionManager class with the following one:

private static bool IsInDesignMode(DependencyObject element)
    return DesignerProperties.GetIsInDesignMode(element);

You can find more information about this issue in the following links:

I hope you find this useful,

Damian Cherubini

Sep 16, 2011 at 2:36 PM
Edited Sep 16, 2011 at 3:51 PM



thanks, this helped a lot. Fixed it!!