private void BtnImport_Click(object sender, RoutedEventArgs e) { if (a == null) { //Instantiate the object and call the Open() method a = new AddScreen("Trans"); a.Show(); //Add a event handler to set null our window object when it will be closed a.Closed += new EventHandler(AddScreen_Closed); } //If the window was created and your window isn't active //we call the method Activate to call the specific window to front else if (a != null && !a.IsActive) { a.Activate(); } a.DataChanged += AddScreen_DataChanged; a.Show(); }
void AddScreen_Closed(object sender, EventArgs e) { a = null; }