简体   繁体   English

显示拥有的窗口而不显示在前面

[英]Show an owned window without bringing to front

A window without an owner is shown from a main window. 从主窗口显示没有所有者的窗口。 The main window then shows a window it owns. 然后,主窗口显示其拥有的窗口。 The owned window brings itself and the main window to the front. 拥有的窗口将自身和主窗口置于最前面。

I would like the owned window and the main window to stay behind the window without an owner. 我希望拥有的窗口和主窗口在没有所有者的情况下保持在窗口后面。 Setting the property ShowActivated to false on the owned window does not prevent the windows from bringing themselves to the front, but does prevent stealing focus. 在拥有的窗口上将属性ShowActivated设置为false不会阻止窗口将自己移到最前面,但是可以防止窃取焦点。

Any ideas on how to get the owned window to stay behind the ownerless window when calling Show? 关于在调用Show时如何使拥有的窗口保持在无主窗口后面的任何想法?

Window ownerlessWindow = new OwnerlessWindow();
ownerlessWindow.Show();

Thread.Sleep(1000);

Window child = new ChildWindow();
child.ShowActivated = false;
child.Owner = this;
child.Show();

// Bring the ownerless window to the front
ownerlessWindow.Topmost = true;
ownerlessWindow.Topmost = false;
ownerlessWindow.Focus();

In the test application, the above code does put the ownerless window back in the front without a visible change in the window order. 在测试应用程序中,上面的代码确实将无主窗口放回了前面,而窗口顺序没有明显变化。 In the production application, there is a quick, visible change in the window order. 在生产应用程序中,窗口顺序有一个快速可见的变化。

Window ownerlessWindow = new OwnerlessWindow();

// set the ownerless window topmost first
ownerlessWindow.Topmost = true;
ownerlessWindow.Show();

Thread.Sleep(1000);

Window child = new ChildWindow();
child.ShowActivated = false;
child.Owner = this;
child.Show();

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

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