12

I am developing an application in C#. I'm using .Net under WPF. I want to open a new child window (like a dialog) and it should open within the main window, just below the menu bar.

However, the newly opened windows is simply showing an OS task bar. How can I open the various new windows(like a dialog box) under the main window?

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Mukthi
  • 561
  • 4
  • 13
  • 35

1 Answers1

26

Try this.

MyChildWindow cw = new MyChildWindow();
cw.ShowInTaskbar = false;
cw.Owner = Application.Current.MainWindow;
cw.Show();
Henry
  • 1,010
  • 8
  • 10
  • If you have multiple windows and the Application.Current.MainWindow is not the desired Window, You could use VisualTreeHelper.GetParent to traverse the tree until you reach the current window. – dowhilefor Sep 10 '11 at 19:09
  • 9
    For a dialog, you should use ShowDialog as opposed to Show. – sellmeadog Sep 11 '11 at 00:40