简体   繁体   中英

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.

Any ideas on how to get the owned window to stay behind the ownerless window when calling 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();

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