private void CreateNewDocument(DockWindowViewModel dockWindowViewModel) { dockWindowViewModel.PropertyChanged += DockWindowViewModel_PropertyChanged; if (!dockWindowViewModel.IsClosed) { this.Documents.Add(dockWindowViewModel); } }
private void DockWindowViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { DockWindowViewModel document = sender as DockWindowViewModel; if (e.PropertyName == nameof(DockWindowViewModel.IsClosed)) { if (!document.IsClosed) { this.Documents.Add(document); } else { this.Documents.Remove(document); if (Documents.Count == 0) { ActiveDockWindow = null; } } } }