在父窗口之上的儿童wpf窗口

时间:2022-06-07 19:57:10

I have WPF application with main window. I want to create child WPF window wich always must be above ONLY parent window. If I set TopMost property for new window then window is above ALL nonTopMost windows on desktop. It's not what I want. Any help? Thanks in advance.

我有主窗口的WPF应用程序。我想创建子WPF窗口,它总是必须在父窗口之上。如果我为新窗口设置TopMost属性,则窗口位于桌面上的所有nonTopMost窗口之上。这不是我想要的。有帮助吗?提前致谢。

2 个解决方案

#1


12  

Set the Owner property of the child window so that it refers to the parent window.

设置子窗口的Owner属性,使其引用父窗口。

child.Owner = parent;

#2


1  

Depending on the nature of the window, I often use a "Fake" window that is really just a layer in the parent along with a partailly transparent grey layer between that makes the parent look ghosted while the child is active. You can then keep the child window set to collapsed until it is needed.

根据窗口的性质,我经常使用一个“假”窗口,它实际上只是父窗口中的一个层,并且在窗口之间有一个部分透明的灰色层,这使得父窗口在子窗口处于活动状态时会显示为幻影。然后,您可以将子窗口设置为折叠,直到需要它为止。

#1


12  

Set the Owner property of the child window so that it refers to the parent window.

设置子窗口的Owner属性,使其引用父窗口。

child.Owner = parent;

#2


1  

Depending on the nature of the window, I often use a "Fake" window that is really just a layer in the parent along with a partailly transparent grey layer between that makes the parent look ghosted while the child is active. You can then keep the child window set to collapsed until it is needed.

根据窗口的性质,我经常使用一个“假”窗口,它实际上只是父窗口中的一个层,并且在窗口之间有一个部分透明的灰色层,这使得父窗口在子窗口处于活动状态时会显示为幻影。然后,您可以将子窗口设置为折叠,直到需要它为止。