【发布时间】:2014-07-11 16:12:30
【问题描述】:
在我的 wpf 应用程序中,我尝试使用 Windows 窗体控件....但我收到一个错误,即 错误找不到类型“WindowsFormsHost”。确认您没有丢失程序集引用并且所有引用的程序集都已构建。 谁能帮我完成它...以下是我的代码
c#:code
public Window2()
{
InitializeComponent();
System.Windows.Forms.PictureBox PictureBox1 = new System.Windows.Forms.PictureBox();
windowsFormsHost1.Child = PictureBox1;
PictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(PictureBox1_Paint);
}
xaml:code
<WindowsFormsHost Height="175" HorizontalAlignment="Left" Margin="10,10,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="255" />
【问题讨论】:
-
你确定你已经包含了这个
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"和xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" -
是的,我添加了这些引用...
-
你用过
WindowsFormsIntegrationref 吗? -
没有。如何添加此引用?我应该将此 WindowsFormsIntegration.dll 添加到我的应用程序吗?