I am currently developing an application that allows the use of plugins. One of the features is that the plugin could expose a settings UI that the hosting application would embed somewhere for the user to see.
What I am wondering is if there is some way that I can add a property to my plugin interface that will allow a plugin developer to create either a wpf or winforms UI and expose it through this property while keeping the property typed? (ie. not using “object” as the property type), or without the use of seperate properties (ie. WPFUI, WinFormsUI) etc.
The two technologies work very differently. I would recommend either exposing a Windows.Forms.Control or a FrameworkElement, but not both (at least not from the same plugin API).
If you expose a
Control, it’s simple for a WPF control to be served up using an ElementHost. Likewise, aFrameworkElementcan be provided by a Windows Forms plugin via a WindowsFormsHost.My decision here would be more in terms of how the host application is developed. If you’re using WPF, I would strongly recommend exposing the plugin as a
FrameworkElement, as this provides you a lot more flexibility. If your main application is going to be Windows Forms based, then just exposing aControlis simple.If you don’t want this added complexity, I’d actually recommend two separate APIs – one for Windows Forms users and one for WPF users, as this keeps the simplicity on the end users’ part the same. Depending on the plugin mechanism, this is typically fairly simple to provide.