MattP
MattP

Reputation: 2863

Closing a Window in WPF (When not in that Window)

I have an application which starts with a simple start screen allowing the user to select either New or Open a project. When selecting New I have a new window displayed which is a wizard that collects data to be passed to the Main window.

I create a new Window for the Main window and show that. Then I close the wizard easily enough with this.close(); But how do I close the initial window which is the Startup URI window?

Upvotes: 1

Views: 1220

Answers (2)

Robert Levy
Robert Levy

Reputation: 29083

Application.Current.MainWindow.Close();

Upvotes: 6

SLaks
SLaks

Reputation: 888203

Pass the Startup window to the main window as a constructor parameter or property, then call Close() on it.

Upvotes: 0

Related Questions