How to use WinForms/WPF as ActiveX control? - wpf

I would like to use WinForms/WPF controls as if they were ActiveX controls.
Specifically I would like to host these controls inside SAP Business One or it may be outside
of SAP B1.
Is this possible at all? If yes, I would like to see some examples.
Thanks in advance,

Yes, it's possible. The machine running SAP Business One will still need the .NET framework, of course, but yes, you can expose your controls as ActiveX objects.
Have a look at this article: WPF Vista Gadgets using ActiveX. Referenced in that article is a sample WPF ActiveX control. That should get you started.

Related

Is Silverlight a subset of WPF?

Is Silverlight a subset of WPF? If i learn WPF then can i say i know Silverlight too?
Silverlight is similar to WPF, and actually started out as WPF/E (WPF Everywhere) but at some point, it became a separate implementation and it is not directly compatible with WPF.
That said, most of the techniques and classes that you would learn in WPF will have a Silverlight variant. One primary exception being the 3D visualization facilities in WPF are not available in Silverlight.
Silverlight is still coded in a Silverlight-specific .NET run-time (a slimmer version than the full .NET run-time) and you still use XAML to describe your presentations.
It should also be noted that Silverlight does have built-in restrictions with accessing resources on the machine it is running on. For example, Silverlight applications can not access the registry. There are enhancements in Silverlight though that do allow for "out of browser" applications which can be given full-trust privileges.
The one big difference between Silverlight and WPF is the CLR (Common Language Runtime) and that Silverlight is Sandboxed, so you don't get alot of functionality you can get with WPF.
If you know WPF XAML and Model-View type aspects of programming styles with e.g Dependency propertys then you will find it quite easy to use Silverlight.
One big thing with Silverlight is that you cant reference C# non silverlight classes, you must use these types of classes via WCF.

Can i use Activex with silverlight4?

I need to use a ActiveX control in my silverlight application. After some research i found out a few ways in which a silverlight app can use ActiveX control
Use ActiveX control in a webpage along with silverlight plugin and use javascript for interaction between silverlight and activex.
Use a webbrowser control in silverlight 4 and load the webpage containing activex in webbrowser control.
Is there any other way that can utilized to embed activex control in silverlight app. I read somewhere that silverlight 4 has support for COM components. Can silverlight4 provide support for embedding activex control in a silverlight app.
Any help on this is highly appreciated and if some samples/documentation link is there that would be great.
Thanks in advance.
Silverlight does have support for COM automation servers like those used with Microsoft Office. It doesn't have general support for COM though and even if it did, ActiveX controls have very specific hosting requirements.
The idea of using the browser control is a possibility, but it will introduce some significant limitations. For one, you cant use the WebBrowser control in Silverlight unless you're running in out-of-browser mode which means your users would have to take steps to install the Silverlight application.
Additionally, the WebBrowser control (including any ActiveX controls it contains) will always render above your Silverlight content and won't be able to participate in transforms, animations, styling, etc. In other words it will stick out like a sore thumb.
What kind of control is it? Perhaps there is an alternative?

Using ActiveX control in WPF

I'm attempting to host an ActiveX control in a WPF app. After attempting to use existing info on the web and here, I've hit a dead-end.
I need to use an ActiveX control provided to communicate with a UV power meter. They provide an application that registers and uses the control and even includes some useful demo apps. I stripped out the OCX file and put it here if needed. You won't have the power meter to talk to, but the app and demos will still load the ActiveX control successfully.
I created a simple Windows Forms application. I was able to bring the ActiveX control into the toolbar, drop it into my form, and everything is fine. The demo apps they provide do this as well.
However, getting this to work in a WPF environment is another story. The control can't be added to the toolbox and "dragged" into the app.
So far I've tried two techniques:
Technique found here. I am able to add a reference to the control, but then I enter namespace hell. The xmlns:ax namespace it suggests making cannot find the information. Here's my attempt based on what the object viewer tells me: xmlns:ax="clr-namespace:OphirUsbXLib;assembly=Interop.OphirUsbXLib"
Technique found here. This is essentially to create a new project that creates a library based on Windows Forms, which contains the ActiveX control (yikes). I am able to add the Windows Forms Host, but I cannot get access to the ActiveX control within. I can make the control public, but I still cannot call methods etc. This doesn't look like the right solution.
In short, I have an ActiveX control that works beautifully in Forms, but is a real bitch to get working in WPF.
Any insight is appreciated!
In this situation I would consider making a WinForms usercontrol which wraps the ActiveX control you are trying to use.
You could make public properties and methods which expose each of the required properties and methods on the ActiveX control, and then host this WinForms UC on the in a WPF WinFormsHost control.
I have already done something similar to this, in reverse, hosting a WPF UserControl in a WinForms UserControl, then hosting that on a VB6 Form in a legacy application.

Can we host a VB6.0 user control in WPF forms?

Can we host a VB6.0 user control in WPF forms?
VB6 user controls are ActiveX
Walkthrough: Hosting an ActiveX Control in Windows Presentation Foundation
Maybe, maybe not. .NET can handle COM/ActiveX controls so there should be a way to do this.
But you would include non-managed code to your project. Not only would this make your code a lot less reliable, it also would make the installation much more complex. In general, it's not worth the trouble.

Can I use Silverlight in an ActiveX Control?

I would like to create an ActiveX control that uses Silverlight. Is this possible/sensible and does anyone have an sample code for this?
I am working in a legacy (non web) system that cannot directly use WPF/Silverlight controls. But the system can access ActiveX controls. The thought is that we may be able to host Silverlight in an ActiveX control, and therefore update our rather dated UI.
Read this article.
Silverlight COM Ref.
The article indicates activeX controls in 'agcore.dll' On windows it is actually imported through 'npctrl.dll'.
you compile may have some sort of activex control wizard.
EDIT: With that said. It might be as easy to host IWebBrowser in an activeX control and embedd silvelight into the browser control from local storage via 'xaml'.

Resources