Click here to Skip to main content
12,501,845 members (53,962 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

23.6K views
4 bookmarked
Posted

Set Owner of a WPF Window to a Form

, 28 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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:
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)

Share

About the Author

Akos Orban
Student
Poland Poland
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionExactly what I was looking for! Pin
morgi_a30-Jan-15 4:53
membermorgi_a30-Jan-15 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 28 Nov 2011
Article Copyright 2011 by Akos Orban
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid