For windows, there is no such relationship as child-parent.
There is main window and other windows, this is all which makes the difference. Also, there is an optional ownership relationship, but it's irrelevant to the issue. What window instance is main is defined by current
Application
object, this is the window which was passed as a parameter to
Application.Run
. All other windows can be shown via
Window.Show
or
Window.ShowDialog
. The second case simulates
modal behavior. So, even the same
Window
instance can be shown in a modal or not modal way. I have no idea of your
CustomDialog
type; you should have shown it. The recommended way of doing custom dialogs are using the same very
Window
class as a base class.
That's all. Now, the default behavior is this: if you close a non-main window shown via
Window.Show
, you just close it and effectively lose it. You can prevent is and hide it instead, to show later; this is one of the most popular technique. If the window is shown via
Window.ShowDialog
, you just close it, and, when it is modal, you cannot touch any other window, not main, not any one else.
And then, in contrast to all the above, by default, closing the main window not only closes all the window, it also exits the application — unless you prevent it. If you prevented it and don't realize how, nothing could help except getting to understand each like you write. You did not show anything like that, anyway. In other words, by default,
there is nothing you need to do. If you exit the application, it exists; there are no windows, nothing.
Yes, you can prevent it. Then you can exist the application explicitly. In this case, there is no a need to close other windows explicitly using
Application.Shutdown
. See also:
Application.ShutdownMode Property (System.Windows)[
^].
It's possible that the attempt to close another window prevents application shutdown. If you made some effort to prevent closing of a window, the exclusion should be made for all actions except closing by the user. This is how you could cancel closing. Normally, it's done only on some conditions (data wasn't saved, and loosing data is not confirmed be the user):
Window.OnClosing Method (CancelEventArgs) (System.Windows)[
^],
CancelEventArgs Class (System.ComponentModel)[
^].
If you don't do anything like that, than again, there is nothing you need to do.
—SA