private void BtnASN_Click(object sender, RoutedEventArgs e) { if (asnForm == null || asnForm.IsActive) { asnForm = new ASN(); asnForm.Show(); //Add a event handler to set null our window object when it will be closed asnForm.Closed += new EventHandler(newasnForm_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 { asnForm.Activate(); } }
void newasnForm_Closed(object sender, EventArgs e) { asnForm = null; }