如何在Windows表单中托管基于DryIoc的Prism WPF应用程序?



我已经使用DryIoc容器开发了一个基于棱镜的WPF应用程序,现在我想将其托管在Windows表单应用程序中,但是我找不到如何使用元素主机在Windows表单中托管此应用程序。

DryIoc引导程序类是在"Prism.DryIoc.Wpf"中定义的,所以我在我的 winforms 应用程序中添加了引用,但这种方法的问题在于,当我尝试覆盖"CreateShell"方法时,它会返回 DependencyObject,我不能在 winforms 上下文中使用,

protected virtual System.Windows.DependencyObject CreateShell();

关于如何使其工作的任何指示? 提前谢谢。

这是让引导程序工作的方法。 使用杂注来抑制已弃用的警告。 希望这有帮助。

命名空间 XXX {

杂注警告禁用 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;
}
}

杂注警告恢复 0618

}

最新更新