tags:

views:

1158

answers:

1

Is there a way to find out the z-order of all active windows in my application (application.current.windows) or any other way to find out what is the "parent" window of a modal window?

I am trying to implement a "shader" functionality, that should fade the parent window when a modal window is shown. (the only way I have found so far is to pass the "parent" window as a parameter, but I don't really like it this way) .

+2  A: 

You should pass it the parent window anyway, otherwise you might run into weirdness if the user toggles between your app and some other one (I had to fix this just last week.:)). Windows have an Owner property that you should set when showing a modal window:

bool? res = new MyWindow(){Owner = this}.ShowDialog();

Then you can use the Owner property from the child window:

if (Owner != null) {
 Owner.DoWhateverYouWant();
}
Ria
Great idea Ria.Not exactly what i was looking for, but still much better than creating a new parameter just for the "parent" form.
Entrodus