标题几乎说明了一切,但基本上我有一个主父窗口,它偶尔会打开子窗口。现在可以从 Windows 7 任务栏中选择一个子窗口,并且只有那个窗口会被带到前面。我希望它找到一种将父窗口链接到此命令的方法,以便在任何时候选择子窗口时,父窗口也会自动被带到前面。
我尝试在子窗口“GotFocus BringIntoView()”方法中同时使用Focus()
和Topmost = true
命令,但同样没有乐趣。event handler, but neither seemed to make a difference. I also tried the
有没有人见过这个或者知道实现这个的方法?
这是我到目前为止所尝试的。mainWindow
先设置然后立即设置子窗口的逻辑是我仍然希望子窗口具有焦点,但我希望mainWindow
高于任何其他正在运行的程序(即 Excel、VS 等)。
private void Window_GotFocus(object sender, RoutedEventArgs e)
{
var mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
mainWindow.Topmost = true;
this.Topmost = true;
}