tags:

views:

132

answers:

1

I'm new to Prism and I am attempting to host a Prisim control within an ElementHost. I seem to be missing something very basic. I have a single WinForm that contains an ElementHost. The following code is in the form:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        Bootstrapper bootstrapper = new Bootstrapper();
        bootstrapper.Run();

        var child = bootstrapper.Container.Resolve<Shell>();
        elementHost.Child = child;

    }

The BootStrapper handles regisration

public class Bootstrapper : UnityBootstrapper
{
    protected override DependencyObject CreateShell()
    {
        Container.RegisterType<MyView>();
        var shell = Container.Resolve<Shell>();
        return shell;
    }

    protected override IModuleCatalog GetModuleCatalog()
    {
        ModuleCatalog catalog = new ModuleCatalog();
        catalog.AddModule(typeof(MyModule));
        return catalog;
    }
}

The MyView.xaml is nothing more than a label at this point.

Shell.xaml is a UserControl that contains the following XAML:

<ItemsControl Name="MainRegion" cal:RegionManager.RegionName="MainRegion" />

The module code is minimal:

public class MyModule : IModule
{
    private readonly IRegionViewRegistry _regionViewRegistry;

    public MyModule(IRegionViewRegistry registry)
    {
        _regionViewRegistry = registry;   
    }

    public void Initialize()
    {
        _regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(MyView));
    }
}

I've been tracing deep into the Prism code trying to figure out why the View is never set into the region. Am I missing something basic?

A: 

The answer was found on this blog

Mark Lindell