Sergey
Sergey

Reputation: 11908

WPF multiple windows in the same location after another

If there's a WPF project with a lot of windows of the same size, what should I do to make the windows be in the same location while switching between them. For example there's one window, I click next button to hide this window and show the second, next window appears but it is in another place. How to control the place of window apperance?

Upvotes: 1

Views: 1361

Answers (4)

PIntag
PIntag

Reputation: 962

There are some good suggestions here but an approach I might use is to have your main window contain a ContentControl that takes up the space where you want the windows to appear. Then, make each of your windows a UserControl. This will allow you to assign any of these UserControl windows to the ContentControl. This method is well-suited when using MVVM.

Upvotes: 0

Mohammad Zare
Mohammad Zare

Reputation: 1509

if you want to have a second window in the center of the first window you must use it:

1 - Set this property of the second window WindowStartupLocation = CenterOwner 2 - In the first window and in your button Click event (or everywhere you want) write this:

SecondWindow s = new SecondWindow();
s.owner = this;
s.ShowDialog();

Upvotes: 0

Emond
Emond

Reputation: 50672

Have a look at a Wizard Control, there are many more just search the web.

That it will save you from reinventing the wheel and littering the taskbar.

Upvotes: 0

parapura rajkumar
parapura rajkumar

Reputation: 24403

Set all the windows to have the same Height/Width and Left and Top properties and stack them behind each other.

But you can just change your approach altogether. You have change your Windows to be be Page and use NavigationService.

See http://msdn.microsoft.com/en-us/library/ms750478.aspx http://www.paulstovell.com/wpf-navigation

Upvotes: 1

Related Questions