Reputation: 1401
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?
Upvotes: 0
Views: 3676
Reputation: 2265
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
Upvotes: 3
Reputation: 1401
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.
Upvotes: 1