private void ViewOnClosing(object sender, CancelEventArgs cancelEventArgs) { if (!TryClosing()) { cancelEventArgs.Cancel = true; return; } cancelEventArgs.Cancel = false; Closing(); View.Closing -= ViewOnClosing; View.ViewModel = null; ViewModelManager.Deregister(this); foreach (var win in View.OwnedWindows) { var view = win as View; view?.Close(); } View = null; isClosing = true; }