diff --git a/source/Components/AvalonDock/Controls/LayoutDocumentPaneControl.cs b/source/Components/AvalonDock/Controls/LayoutDocumentPaneControl.cs index 53944d2d..da2c900f 100644 --- a/source/Components/AvalonDock/Controls/LayoutDocumentPaneControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutDocumentPaneControl.cs @@ -96,7 +96,7 @@ protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) { foreach (var item in e.OldItems) { - if (item is LayoutContent layoutContent) + if (item is LayoutContent layoutContent && layoutContent.TabItem != null) { layoutContent.TabItem.Model = null; layoutContent.TabItem.ContextMenu = null;