[RhinoCommon] Unable to add wpf panel

rhinocommon
rhino5
panelingtools

#1

Hi,

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?

Thanks,
Yuliya


(Menno Deij - van Rijswijk) #2

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:
http://www.wpf-tutorial.com/misc-controls/the-windowsformshost-control/


(Dale Fugier) #3

Here is a simple example that might help you.


#4

Thank you! This helped me so much.


#5

Could you please update this link?


(Dale Fugier) #6

How about this?

– Dale