简体   繁体   English

如何将窗体窗口的所有者设置为 WPF Window?

[英]How can I set Form Window's owner to WPF Window?

My application is built in WPF .NET Framework.我的应用程序构建在 WPF .NET 框架中。

I have an WPF MainWindow and I want to make several FormWindows as children of the WPF MainWindow.我有一个 WPF MainWindow,我想将几个 FormWindows 作为 WPF MainWindow 的子窗口。 When making child WPF Window of parent WPF Window, I can simply put Owner = this to child window but it does not work on Form Window, of course. When making child WPF Window of parent WPF Window, I can simply put Owner = this to child window but it does not work on Form Window, of course.

is there any way to make it possible?有没有办法让它成为可能?

thanks in advance提前致谢

No, you cannot set the Owner property of a WPF window to anything else than another WPF window.不,您不能将 WPF window 的Owner属性设置为除另一个 WPF Z05B8C74CBD9706FBF2FZ4C1 之外的任何其他内容。

There is a WindowInteropHelper class that has an Owner property that can be set to the HWND of a form: WindowInteropHelper class 有一个Owner属性,可以设置为表单的 HWND:

Form1 form = new Form1();
WindowInteropHelper wih = new WindowInteropHelper(wpfWindow);
wih.Owner = form.Handle;

Another suggestion would be to skip the forms and move the contents of the forms into WPF windows, for example using the WindowsFormsHost control.另一个建议是跳过 forms 并将 forms 的内容移动到 WPF Z0F4137ED1502B5045D6083A2中,例如使用 Windows8FormsBHostCAA2 控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM