Embedding a Rhino.UI.Controls.ViewportControl into a xaml form

I have been trying to embed a Rhino Viewport into my XAML form. I’m thinking the only way to do this will be to create my form with a blank square and add the ViewportControl in during runtime.

I have had a read through and play with SampleCsEtoViewportCommand which was very helpful and tried to add it to my project, this lead me to Eto and as such I have referenced in Eto.dll from the Rhino 7 WIP Folder because the NuGet package seems to have issues.

// SampleCsEtoViewportCommand

`internal class SampleCsViewportForm : Dialog
public SampleCsViewportForm()
Title = “Rhino Viewport in an Eto Control”;
Resizable = true;
var viewport_control = new
new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)},
new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)}

  Content = new StackLayout
    Padding = new Padding(2),
    Spacing = 5,
    HorizontalContentAlignment = HorizontalAlignment.Stretch,
    Items =


I have a read through the Eto Wiki on GitHub and found no help in the XAML section XAML Tips & Tricks but I did find a section for how to embed Eto.Forms into another application Embed Eto Forms

However I got stuck there on trying to find more on the .ToNative() property that seems to convert an Eto Form to a Windows Form.

System.Windows.Forms.Control myEtoControlAsWinForms = eto.ToNative(true);

I assume I could replace eto with the new StackLayout I created earlier but that doesn’t seem to work.


It is possible to “host” WindowsForms controls in a WPF XAML layout using the WPF WindowsFormsHost element. No need to use Eto I think.

See https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml for more details.

This is very helpful, thankyou Menno!
Although it doesn’t solve everything as the Eto Control Is not a Windows Control and I need to cast/convert it somehow using the .ToNative(true)

Hey @dale, as you created the SampleCsEto and SampleCsWpf projects do you have any ideas?

Hi @csykesm

Let me know if the attached is helpful.

SampleWpfViewport.zip (26.2 KB)

– Dale

1 Like

Thanks @dale,

that sample works perfectly!
I’ll probably use this WindowsFormHost plenty more in the future too :smiley:

1 Like

@dale When bringing in RhinoInside nuget package v7.0.0 RhinoWindows.dll does not get copied into the Bin folder. RhinoInside expects the Version=, Culture=neutral, PublicKeyToken=552281e97c755530. The nuget package RhinoWindows 8.0.21131.12305-wip does not seem to produce the RhinoWindows.dll in the Bin folder either. The version in the Rhino folder is 7.4. What am I doing wrong? Thanks

It sounds like you got nuget packages installed for Rhino 8. I would recommend using the Rhino 7 version.

You don’t want RhinoWindows to be copied to your bin folder. RhinoInside loads Rhino as a library from its installed location and gets other associated DLLs to also be loaded from that location.

Thanks @stevebaer ! That problem occurred even with Rhino 7 versions of Nuget Packages. However you pointed me in the right direction. The issue was that the call
needs to be made before WPF control is initialized. When I added this call in the window constructor, Rhino Inside is able to find the right dlls.