Open a window in front of the current one with the mouse Event

The window opened in Button Click Method is displayed in the front of the parent Window.

void OnButtonClick(object sender, RoutedEventArgs e)
{
MyWindow window=new MyWindow();
window.Show();
}

But, when i tryed the mouse, the new window is at the behind.

void OnDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
MyWindow window=new MyWindow();
window.Show();
}

How can i open a window in front of the current one with the mouse Event

cheers



Answer this question

Open a window in front of the current one with the mouse Event

  • brireed

    You have to open the new window as modal dialog:

    Window window = new Window();
    window.ShowDialog();

    Sheva


  • Hengyi Liu

    Thanks for you quick reply, Sheva.

    I also tryed the showDialog();

    But new problem is in the case of modal dialog, the parent window is 'locked'. If i want it be 'alive' , What should i do


  • Rocky101

    Can you try this

    MyWindow window = new MyWindow();

    window.Show();

    window.Focus();


  • Open a window in front of the current one with the mouse Event