0
votes

I have developed a Prism based WPF application using DryIoc container now I want to host it inside the windows forms application, But I couldn't find out how to host this application inside windows forms using element host.

DryIoc bootstrapper class is defined inside "Prism.DryIoc.Wpf" so I added the reference in my winforms application, but the problem with this approach is that when I tried to override the "CreateShell" method it returns DependencyObject which I can't use in winforms context,

protected virtual System.Windows.DependencyObject CreateShell();

Any pointers on how to get it working ? Thanks in advance.

1
Prism is for WPF, as you already noticed, if you want WinForms, use a different framework. Or build two different applications and embed one into the other using pinvoke...Haukinger
Thanks for your reply, it seems possible. I was able to get it working, I am still testing my approach I will share my answer in a day for others.Karthik Mahalingam

1 Answers

0
votes

Here is the way to get bootstrapper working. Use pragma to supress the deprecated warning. Hope this helps.

namespace XXX {

pragma warning disable 0618

public class xxxBootstrapper : DryIocBootstrapper
{
    MainControl mainControl;
    public xxxBootstrapper ()
    {
        base.ConfigureViewModelLocator();
    }
    protected override DependencyObject CreateShell()
    {
        mainControl = new MainControl();
        return mainControl;
    }


    protected override void ConfigureModuleCatalog()
    {
        //Load modules..

        base.ConfigureModuleCatalog();
    }

    public UIElement GetMainControl()
    {
        return (UIElement)mainControl;
    }
}

pragma warning restore 0618

}