Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 242
David Gray Wright Avatar asked May 25 '11 23:05

David Gray Wright


1 Answers

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.

like image 137
jschroedl Avatar answered Nov 14 '22 20:11

jschroedl