Set Wpf parent to a MDIform

江枫思渺然 提交于 2019-12-25 04:57:27

问题


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?


回答1:


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;
    }



回答2:


There is an open-source MDI implementation for WPF that you might want to look at. It may be a good bit of work and re-structuring of your code, but if you absolutely must have MDI, then that may be the best way to go forward with this - MDI for WPF.



来源:https://stackoverflow.com/questions/13044618/set-wpf-parent-to-a-mdiform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!