Rhioncommon WPF Modeless

Hi,

In this example we can see how to create a SemiModal WPF Dialog

But I noticed that when the dialog is open we are limited…cannot really execute Rhino Commands. What would be the best way to create a completely Modeless WPF Window (with the Rhino MainWindow as the owner)?

P.S. I am trying something like this at the moment, but it is not working well yet… Rhino Window does not own the new dialog…

UImain = new UI();
UImain.Owner = RhinoWinApp.MainWindow as System.Windows.Window;
UImain.Show();

Thanks!

Not quite sure about it. But the problem is probably that you start the window from a command on the GUI thread. In other words the ULMain.Show(); and so the command stops executing only if you close the window.
In order to terminate the command, you’ll need to open the dialog on another STA thread.

Do not create a window on another thread to solve this issue. The problem is that you are casting RhinoWinApp.MainWindow to a WPF System.Windows.Window and this cast will resolve to null because MainWindow is not an instance of a System.Windows.Window.

In RhinoCommon, there is a function to get the main window handle at
Rhino.RhinoApp.MainWindowHandle()

Use this function in combination with the WindowInteropHelper class to work with WPF.

1 Like

Thanks @stevebaer
SOLVED.