简体   繁体   English

从第3方DLL调用控件

[英]Calling a control from 3rd Party DLL

I am using a control from a dll in my html page as 我正在使用HTML页面中dll中的控件作为

<object id="ATT"  width="100%" height="100%" 
        classid="CLSID:E20EC898-E4EE-4A20-A5A5-E10144FDC6BA" 
        codebase="AvtechMediaControl.cab#version=1,1,7,6" VIEWASTEXT>
</object>

But I want to access the same into my WPF application. 但是我想在WPF应用程序中访问它。

When I try to choose the DLL in the toolbox, i get the following error, 当我尝试在工具箱中选择DLL时,出现以下错误,

“The following controls were successfully added to the toolbox but are not enabled in the active designer” “以下控件已成功添加到工具箱,但未在活动设计器中启用”

I need a way to add it into my WPF project. 我需要一种将其添加到WPF项目中的方法。 I do not want to go with the webbrowser control. 我不想使用webbrowser控件。

ActiveX controls cannot be directly added to a WPF view, but then can be hosted inside of Windows Form control. ActiveX控件不能直接添加到WPF视图,但是可以在Windows Form控件内部托管。 And WPF can host WinForms controls. WPF可以托管WinForms控件。 Microsoft has a walk through describing the process . Microsoft 逐步介绍了该过程

The short description of this is that you'll add a WindowsFormHost to you XAML view. 对此的简短描述是,您将向XAML视图添加WindowsFormHost The MSDN walk though shows this being done in the code behind, but the WindowsFormHost can be added in the XAML. 尽管MSDN步行在后面的代码中显示了此操作,但是WindowsFormHost可以添加到XAML中。 Then you'll set the Child of the WindowsFormHost to the ActiveX control. 然后,将WindowsFormHost的子级设置为ActiveX控件。 This will have to be done in the code behind as there is no support for adding ActiveX controls in the XAML editor. 这将必须在后面的代码中完成,因为不支持在XAML编辑器中添加ActiveX控件。

You also need to be aware of the behavior of a hosted control in WPF. 您还需要注意WPF中托管控件的行为。 No WPF content can overlap the hosted control. WPF内容不能与宿主控件重叠。 The hosted control will always draw over top of your WPF content. 托管控件将始终覆盖WPF内容的顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM