Can I create a ActiveX Control from a WPF UserControl and use in a non CLI C++ application?

蓝咒 提交于 2019-12-12 08:44:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/6132241/can-i-create-a-activex-control-from-a-wpf-usercontrol-and-use-in-a-non-cli-c-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!