I'm using Visual Studio, WPF, XAML, C#.
I have a button that opens a new Window, TestWindow1. It only allows one instance of the window at a time, not duplicates.
TestWindow1 always stays in front of MainWindow even when the focus is on MainWindow.
How do I bring MainWindow to front on focus?
Or how do I stop TestWindow1 from always being in front?
// Check if Test Window is already open
private Boolean IsTestWindow1Opened = false;
// Open Test Window
private void btnOpenTestWindow1_Click(object sender, RoutedEventArgs e)
{
// Only allow 1 Window instance
if (IsTestWindow1Opened) return;
MainWindow mainwindow = this;
testwindow1 = new TestWindow1(mainwindow);
testwindow1.Owner = Window.GetWindow(this);
testwindow1.Left = Left - 400;
testwindow1.Top = Top + 0;
testwindow1.ContentRendered += delegate { IsTestWindow1Opened = true; };
testwindow1.Closed += delegate { IsTestWindow1Opened = false; };
testwindow1.Show();
}