是否可以从WPF用户控件创建ActiveX控件并在非CLI C ++应用程序中使用它? [英] Can I create a ActiveX Control from a WPF UserControl and use in a non CLI C++ application?
问题描述
我创建了一个Windows窗体用户控件,可以将其公开为ActiveX控件。现在,我尝试使用WPF UserControl进行相同操作。我注意到的Winforms UserControl基类是ComVisible,但是WPF UserControl类不是。我是想做不可能的事吗?
I have created a Windows Forms UserControl that can be exposed as an ActiveX Control. Now I am trying to do the same with a WPF UserControl. The Winforms UserControl base class I noticed is ComVisible however the WPF UserControl class is not. Am I trying to do the impossible?
是实现此目的的唯一方法是编写WPF控件,然后使用ElementHost将其嵌入Winforms UserControl中,然后公开该Winforms是将UserControl作为ActiveX控件吗?
Is the only way to achieve this to write a WPF control and then embed it in a Winforms UserControl using ElementHost and then expose that Winforms UserControl as an ActiveX control?
推荐答案
是的,我认为ElementHost是您有可能需要使用的方法这个工作。
Yes, I think ElementHost is the approach you will need to use if there is a chance of this working.
这是因为WPF控件本质上是无窗口的,所有内容都通过WPF残障的DirectX曲面以保留模式呈现。
This is because WPF controls are inherently windowless with everything being rendered in retained mode via a DirectX surface which WPF maanges.
有一些用于无窗口 ActiveX控件的接口,但是.NET提供的COM互操作也不会将它们映射到WPF对象上。
There are interfaces for "windowless" ActiveX controls but the COM interop provided by .NET does not map these onto WPF objects either.
这篇关于是否可以从WPF用户控件创建ActiveX控件并在非CLI C ++应用程序中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!