Taimur Adil
Taimur Adil

Reputation: 77

open new WPF window without delay

code to open and close form

    form f1 = new form();
    this.hide();
    f1.show();

i am using above code to open 2nd window but it take time to close and then open. i want to use such mechanism that has been used while installing new software where window will not reopen but content of same window changed. other example: when click on my computer it will open new window but when we click on D: drive it opens in same window... so i am using same mechanism here

Upvotes: 1

Views: 310

Answers (1)

DeshDeep Singh
DeshDeep Singh

Reputation: 1843

You need to hide it and set form2.Closed event to call this.Close().

this.Hide();
var form2 = new Form2();
form2.Closed += (s, args) => this.Close(); 
form2.Show();

Upvotes: 2

Related Questions