This keeps the window ontop of Revit when it is opened, minimises it with Revit and additionally stops the window showing on the task bar.
public void ShowForm(UIApplication uiapp)
{
// If we do not have a dialog yet, create and show it
if (_mMyForm != null && _mMyForm == null) return;
//EXTERNAL EVENTS WITH ARGUMENTS
EventHandlerWithStringArg evStr = new EventHandlerWithStringArg();
EventHandlerWithWpfArg evWpf = new EventHandlerWithWpfArg();
_mMyForm = new Ui(uiapp, evStr, evWpf);
HwndSource hwndSource = HwndSource.FromHwnd(uiapp.MainWindowHandle);
System.Windows.Window wnd = hwndSource.RootVisual as System.Windows.Window;
if (wnd != null)
{
_mMyForm.Owner = wnd;
_mMyForm.ShowInTaskbar = false;
_mMyForm.Show();
}
}
This keeps the window ontop of Revit when it is opened, minimises it with Revit and additionally stops the window showing on the task bar.
Test code originally from here https://stackoverflow.com/questions/55339082/is-this-a-way-to-show-a-modeless-dialog-from-a-dockable-pane-using-wpf (I'm sure you will improve it!)
Cheers,
Mark