简体   繁体   中英

Minimizing a WPF window owned by a Winform is not working as expected

I have a Form control named MyForm , which is the parent of some WPF BaseWindow , named MyWindow .

I'm setting their relationship as follows:

new WindowInteropHelper(myWindowInstance).Owner = myFormInstance.Handle;

And am showing the window using

myWindowInstance.ShowDialog();

The window is set with

ResizeMode="CanResize"

Therefor, it has a minimize button. On minimizing the window, its not minimized as expected, but rather minimized to the bottom of the form.

What I would like to experience is that the parent would be minimized as well. Meaning that minimizing the window, will be translated to minimizing the form.

You probably want to create event handlers to control their behavior relationship when events (minimize) occurred.

For WPF, you could use Window_StateChanged event with checking if this.WindowState == WindowState.Minimized

Then for the WinForm you could do the trick by Resize event and checking if WindowState == FormWindowState.Minimized

If any of these is true, then you could minimize both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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