[RhinoCommon] Unable to add wpf panel


I am trying to create custom panel in Rhino using Rhinocommon.
I found an example https://github.com/mcneel/rhinocommon/tree/master/examples/PanelSamplePlugIn.

But this sample uses Windows Forms to create user control. And when I create WPF user control I get an error:
panelType must implement IWin32Window interface

on line:
Panels.RegisterPanel(this, panelType, “PanelName”, icon);

Indeed, WPF user controls don’t implement this interface and so they don’t have any handle.
IWin32Window contains one property only: IntPtr Handle.

So, is there any way to create custom Panel using WPF technology? Or maybe is it possible to emulate Window handle just for Rhino purposes? Or maybe am I overlooking something?


Rhino as you found out only supports Winforms. Fortunately, inside Winforms you can “host” a WPF control. This is done using the WindowsFormsHost control.

What we do is to create an empty Winforms Form which contains only a WindowsFormHost. Inside that host we show the WPF GUI elements.

For more info:

Here is a simple example that might help you.

1 Like

Thank you! This helped me so much.

Could you please update this link?

How about this?

– Dale