protected override void OnClosing(CancelEventArgs e) { IsClosing = true; if (HostedPane.Items.Count > 0) { var contentsToClose = HostedPane.Items.Cast <ManagedContent>().ToArray(); foreach (var cntToClose in contentsToClose) { //if even a content can't close than cancel the close process, but continue try closing other contents if (!cntToClose.Close()) { //forced closing continues the window close process if (!ForcedClosing) { e.Cancel = true; } } } } if (e.Cancel) { IsClosing = false; } else if (_manager != null) { _manager.UnregisterFloatingWindow(this); } base.OnClosing(e); }