Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Set Owner of a WPF Window to a Form

5.00/5 (17 votes)
28 Nov 2011CPOL 45.7K  
Set Owner of a WPF Window to a Form
Use the following method to set the owner of a System.Windows.Window to a System.Windows.Forms.Form:
C#
public static void setOwner(System.Windows.Forms.Form ownerForm, System.Windows.Window window)
        {
            WindowInteropHelper helper = new WindowInteropHelper(window);
            helper.Owner = ownerForm.Handle;
        }


It might be useful when you are developing an application where you are using WinForms and WPF windows together.

Note: The window will appear always in front of its owner, I use this to display tips, for example.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)