Opening a Wpf form from Rhino Common C# Plugin

HI ,

How can we open a wpf form as popupform in Rhinocommon plugin c#.

We are using the windows usercontrol for the main dock panel for the plugin
when users click on the button in the user dock panel, object of winform is created and show method will display the form.
We are opening the form like below this is for displaying some details

PopupForm popUp = new PopupForm ();

This works fine, but we need to put some ui rich elements.
if we created instance of the wpfForm (popup.xaml) , there are no methods like show();

I can see examples for wpf as dock panels here rhino-developer-samples/rhinocommon/cs/SampleCsWpf at 6 · mcneel/rhino-developer-samples · GitHub

but what I need to popup a form like a messagebox or dialog box.

can anybody give some insights on this.

Hi, the best approach is to simply create your user controls within a external library using Visual studio and simply invoke them from your custom command. This will also allow you to check it from a separate program.
Make sure to invoke the window from the GUI Thread. This might be relevant if your are within an event callback. Yes basically what you showed is the correct way. You could also choose .ShowDialog() if you want it to have a dialog-like behaviour. Make also sure your main control is a window and not a uc.

Hi @nevin.mathew,

– Dale

Thanks alot Tom and Dale for your quick response.

The issue I was highlighting is I was not getting the Show or Show Dialog for the wpf control.

The reason is Rhino C# Project template we dont have option to add wpf pages or forms ,we can only add wpf usercontrol.

is there any reason why the wpf page or forms not showing in the add new items in RhinoCommon plugin project in Visual Studio? I am using 2019 Community Edition

But we can add windows forms.
IF we add a wpf user control, that doesnt have show or showdialog method, might be able to extend the control ,am not sure.

Thanks Dale for the link,

IF we add a new wpf user control we have the xaml like below

UI XAML will be like below

<UserControl x:Class="ImageObjectsPanel.PopUpMessage "

code behind like below

public partial class PopUpMessage : UserControl
        public UserControl1()

I udpated the above Xaml with window tag and in code behind inheriting from window instead of usercontrol , then I was able to access the show or showdialog

<Window x:Class="ImageObjectsPanel.PopUpMessage"
             d:DesignHeight="200" d:DesignWidth="200"
             Height="200" Width="300"

public partial class PopUpMessage : Window
        public PopUpMessage()

After this changes I was able to display a dialog box using the show dialog, I am not sure this is stable or it can break the code in the future or it may behave differently once I deploy to other machines , I haven’t used the this for real scenarios , need to test it .

Uploaded the plugin here

Advanced Easter wishes

Hi @nevin.mathew,

Have you made any progress on this? I have not reviewed your code yet.

– Dale

Thanks Dale for for your reply.
I was able to test it from a sample Dock panel application as mentioned above ,
Its just a plain usercontrol dock with a button, on click of the button it will show a wpf dialog box with progress bar “marquee”.
the dialog box is showing up perfectly.

I am not sure why we don’t have a Wpf page option for add >> new item in Rhino Plugin project, but a the same time we have the win form item to add.

but I didn’t get a chance to incorporate in our core plugin, since we are working on other changes and bug fixes for the plugin

Hi @nevin.mathew,

When you right-click on your project and Solution Explorer and click Add > New Item..., your not seeing this?

– Dale

thanks for your reply
May be I haven’t used much wpf and it was not very straight forward for me to change the user control inheritance
from : public partial class PopUpMessage : UserControl
To : public partial class PopUpMessage : Window to get the window properties.

In wpf solution we have option for adding new wpf page, page has the method to show().

But RhinoCommon plugin project doesn’t have that, it has only the wpf user control. need to update the inheriting class as above .
Rhinocommon plugin solution

wpf solution


May I ask how I would achieve a new wpf-window like that?
I am able to add a user control, but I found no way to get a new window?
There should be an option to create a new window in this dialogue-box below, right?

I just cannot find it. Did I forget to load something?


Hi @tobias.stoltmann,

If you want to use WPF in your Rhino plug-in, then when running the project wizard, check the WPF button

If you blew through that dialog, then just make sure your project has these dependencies:


– Dale

I was able to load the references as following, but…
I am still not able to create a WPF-window.
Sorry for bugging your again. :grimacing:

Hi @tobias.stoltmann,

Open up your project’s .vcproj file in a text editor.

If you see this line:

<Project Sdk="Microsoft.NET.Sdk">

Replace it with this;

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

Does this help?

– Dale

1 Like