Alvin
Alvin

Reputation: 8509

WPF window in a main window

I have few WPF windows.

When I want to open a new window, I will close the current one, and load a new one:

ProductMain productMain= new ProductMain();
productMain.Show();
this.Close(); 

I know you can put user control into window.

Can I load the window in a main window?

Thank you.

Upvotes: 0

Views: 223

Answers (1)

Damian Schenkelman
Damian Schenkelman

Reputation: 3545

You can do something like that by setting the Window's owner property. To get the main window use:

Application.Current.MainWindow

After that, you can set the owner of the ProductMain window:

ProductMain productMain= new ProductMain();
productMain.Owner = Application.Current.MainWindow;
productMain.Show();

Upvotes: 2

Related Questions