internal void CheckContentsEmpty() { if (Items.Count == 0) { bool isMainDocPaneToBeClosed = IsMainDocumentPane.HasValue && IsMainDocumentPane.Value; if (isMainDocPaneToBeClosed) { DockingManager manager = GetManager(); DocumentPane candidateNewMainDocPane = manager.FindAnotherLogicalChildContained <DocumentPane>(this); if (candidateNewMainDocPane != null && candidateNewMainDocPane.GetManager() == this.GetManager()) { ResizingPanel containerPanel = Parent as ResizingPanel; if (containerPanel != null) { containerPanel.RemoveChild(this); } manager.MainDocumentPane = candidateNewMainDocPane; candidateNewMainDocPane.NotifyPropertyChanged("IsMainDocumentPane"); } } else { ResizingPanel containerPanel = Parent as ResizingPanel; if (containerPanel != null) { containerPanel.RemoveChild(this); } } } }