【问题标题】:Hosting a Prism app using UnityBootStrapper in a WindowsForms project在 WindowsForms 项目中使用 UnityBootStrapper 托管 Prism 应用程序
【发布时间】:2014-02-03 23:07:22
【问题描述】:

如何在 WindowsForms 项目中使用 UnityBootStrapper 托管 WPF Prism 应用程序?

我在 Windows 窗体宿主项目中添加了对以下 wpf 程序集的引用

PresentationCore 
PresentationFramework 
WindowsBase Ayatem.xaml 
WindowsFormsIntegration.dll 
Microsoft.Practices.Prism.UnityExtensions

并且我已经删除了 Prism 项目的 app.xaml 文件。 在 win 表单的 ElementHost 控件中,我试图填充 shell,但它不加载模块。

//Create the ElementHost control for hosting the WPF UserControl
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;

//Create the WPF UserControl.
HelloWorld.Shell uc = new HelloWorld.Shell();

//Assign the WPF UserControl to the ElementHost control's Child property.
host.Child = uc;

//Add the ElementHost control to the form's collection of child controls.
this.Controls.Add(host);

我正在使用 hello world 示例 prism 应用程序,截至今天,我的项目只有 1 个模块。

【问题讨论】:

    标签: c# .net wpf winforms prism


    【解决方案1】:

    以下 Codeplex 的 讨论解决了与您尝试完成的情况非常相似的情况:

    请注意,您需要修改 Prism.Desktop 项目中的 ReionManager 的 IsInDesignMode() 方法,因为已针对使用 Cider 时的一个已知问题。您只需要更改方法,重新构建 Prism 库 并将新构建的程序集引用到您的 WinForm 解决方案中。

    我希望这会有所帮助, 问候。

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多