【问题标题】:how to add a WPF dialog to a Winforms project如何将 WPF 对话框添加到 Winforms 项目
【发布时间】:2010-09-22 17:52:28
【问题描述】:

我正在使用面向 .net 3.5 框架的 Visual Studio 2008。我需要将 WPF 对话框添加到 Winforms 项目。我在想,通过添加对 PresentationCore、PresentationFramework 和 WindowsBase.dll 的引用并将 WPF 对话框从测试 WPF 项目复制到有问题的 WinForms 项目应该可以解决问题,但之后当我尝试在设计器中打开 WinForms 对话框工作室时只是崩溃并关闭。 所以基本上问题是如何将 WPF 对话框添加到 WinForms 项目? 谢谢

【问题讨论】:

    标签: wpf winforms winforms-interop


    【解决方案1】:

    将对话框创建为 WPF 用户控件库。使用 Project->Add Existing Item 将其添加到 Windows 窗体应用程序。将 ElementHost 组件添加到 Windows 窗体窗体。将 ElementHost 的 HostedContent 设置为 WPF 用户控件。

    此链接可能对您有所帮助:

    http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx

    【讨论】:

    • 显然现在拖动似乎可以工作了。你的答案是如何使用 win wpf 互操作,例如在 winforms 中嵌入 wpf 控件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-05
    • 2016-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多