0

I have a main window which calls another window with ShowDialog(), lets call it window A. Window A calls another window also with ShowDialog(), lets call it window B.

Whenever window B is closed using Close(), I want Window A to be shown, not the main window.

How am I supposed to do that? I already tried using this.Owner, this.Focus, etc. none of them work.

Note: I am using WPF

here is my code from main window:

WindowsA WA = new WindowsA(); WA.showDialog();

at WindowsA, i call another window WindowsB:

WindowsB WB = new WindowsB(); WB.showDialog();

from WindowsB, I pressed button to close:

Close();

Where should I put the owner?

geothachankary
  • 1,040
  • 1
  • 17
  • 30
Alfred Angkasa
  • 1,381
  • 3
  • 17
  • 35
  • When you do showDialog for window b, shouldn't you set the owner to Window A, Then anything that windows A opens will go back to window a when it's closed. See here: http://stackoverflow.com/a/2045671/4714970 – Aequitas Jun 22 '15 at 04:07
  • 1
    Can you post some code? When trying to replicate your problem, my dialog B returns to dialog A as you would expect. – Loocid Jun 22 '15 at 04:09
  • like @Loocid said when tried to replicate the issue i am also able to return to dialog window A as per your requirement. – Sachu Jun 22 '15 at 04:13
  • update the question. I put the simple code. @Aequitas, I already try to set the owner to Window A. But still didn't work. Loocid, Sachu how many form do you have? I 3 forms, main windows, windows A, windows B. – Alfred Angkasa Jun 22 '15 at 04:21

2 Answers2

3

When you do showDialog for window b, you should set the owner to Window A, Then anything that window A opens will go back to window A when it's closed.

Like this: WA.ShowDialog(this);

This will make this the owner of WA.

See here for more information on this: www.stackoverflow.com/a/2045671/4714970

Aequitas
  • 2,205
  • 1
  • 25
  • 51
1

Sorry, I just figured it out.

Before WA.ShowDialog(), I just set WA.Owner = this;

After that it works.

Correct me if I'm wrong.

Alfred Angkasa
  • 1,381
  • 3
  • 17
  • 35