Search code examples
c#winformsmdiparent

Set Wpf parent to a MDIform


I have a win form application with a MDI Form.

for some reason i used a WPF Window in my application. so i want to ask how can i set WPF window parent to my MDI Form?


Solution

  • The following code should give you the ability to set the owner of the wpf dialog to your win form.

    public static void SetOwner(System.Windows.Forms.Form owner, System.Windows.Window wpfWindow)
        {
            WindowInteropHelper helper = new WindowInteropHelper(wpfWindow);
            helper.Owner = owner.Handle;
        }