将 WPF 控件放入 Windows Forms 窗体? [英] Put WPF control into a Windows Forms Form?
本文介绍了将 WPF 控件放入 Windows Forms 窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 WPF 控件放入 Windows Forms Form
?我很可能会将我的 WPF 控件插入到 Windows.Forms.Panel
中.
How do you put a WPF control into a Windows Forms Form
? Most likely I will be inserting my WPF control into a Windows.Forms.Panel
.
推荐答案
放置一个 ElementHost
面板内的控件.然后,此控件可以承载 WPF 元素.在 WinForms 设计器中,您可以在WPF 互操作性"下找到此控件.首先,您可能需要将 WindowsFormsIntegration.dll
添加到项目的引用中.
Put an ElementHost
control inside the panel. This control can then host a WPF element. From the WinForms designer, you can find this control under 'WPF Interoperability'. First you may need to add WindowsFormsIntegration.dll
to your project's references.
有关示例,请参阅 演练:在 Windows 窗体中托管 WPF 复合控件.
这篇关于将 WPF 控件放入 Windows Forms 窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文