我可以从 WPF UserControl 创建 ActiveX 控件并在非 CLI C++ 中使用吗?应用?
我创建了一个可以作为 ActiveX 控件公开的 Windows 窗体用户控件。现在我尝试对 WPF UserControl 执行相同的操作。我注意到 Winforms UserControl 基类是 ComVisible,但 WPF UserControl 类不是。我正在尝试做不可能的事吗?
实现此目的的唯一方法是编写 WPF 控件,然后使用 ElementHost 将其嵌入到 Winforms UserControl 中,然后将该 Winforms UserControl 公开为 ActiveX 控件?
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?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我认为 ElementHost 是您需要使用的方法(如果有机会实现此目的)。
这是因为 WPF 控件本质上是无窗口的,所有内容都通过 WPF 管理的 DirectX 表面以保留模式呈现。
有一些用于“无窗口”ActiveX 控件的接口,但 .NET 提供的 COM 互操作也不将这些接口映射到 WPF 对象。
Yes, I think ElementHost is the approach you will need to use if there is a chance of this working.
This is because WPF controls are inherently windowless with everything being rendered in retained mode via a DirectX surface which WPF maanges.
There are interfaces for "windowless" ActiveX controls but the COM interop provided by .NET does not map these onto WPF objects either.