Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Prisim within an ElementHost
    text
    copied!<p>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:</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.Run(); var child = bootstrapper.Container.Resolve&lt;Shell&gt;(); elementHost.Child = child; } </code></pre> <p>The BootStrapper handles regisration</p> <pre><code>public class Bootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { Container.RegisterType&lt;MyView&gt;(); var shell = Container.Resolve&lt;Shell&gt;(); return shell; } protected override IModuleCatalog GetModuleCatalog() { ModuleCatalog catalog = new ModuleCatalog(); catalog.AddModule(typeof(MyModule)); return catalog; } } </code></pre> <p>The MyView.xaml is nothing more than a label at this point.</p> <p>Shell.xaml is a UserControl that contains the following XAML:</p> <pre><code>&lt;ItemsControl Name="MainRegion" cal:RegionManager.RegionName="MainRegion" /&gt; </code></pre> <p>The module code is minimal:</p> <pre><code>public class MyModule : IModule { private readonly IRegionViewRegistry _regionViewRegistry; public MyModule(IRegionViewRegistry registry) { _regionViewRegistry = registry; } public void Initialize() { _regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(MyView)); } } </code></pre> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload