When a DockingManager is created but is never visible (for example in a TabItem of a TabControl), _autoHideWindowManager member stays null. But when this DockingManager is unloader, the event handler DockingManager_Unloaded is called and there is an exception on "_autoHideWindowManager.HideAutoWindow();" line since _autoHideWindowManager is null.
I think that this code :
if (_autoHideWindowManager != null)
{
_autoHideWindowManager.HideAutoWindow();
}
should be better to manage this case (DockingManager never visible before to be unloaded)
Comments: ** Comment from web user: rickSaw **
So I gave my vote, but did we ever get a work around for this issue?
I have the same issue as the original, my dockingManager is in a tab control. I tried the null reference check but was still given the NullReferenceException.
```
void DockingManager_Unloaded(object sender, RoutedEventArgs e)
{
if (!DesignerProperties.GetIsInDesignMode(this))
{
if (_autoHideWindowManager != null)
{
_autoHideWindowManager.HideAutoWindow();
}
foreach (var fw in _fwList.ToArray())
{
//fw.Owner = null;
fw.SetParentWindowToNull();
fw.KeepContentVisibleOnClose = true;
fw.Close();
}
DestroyOverlayWindow();
FocusElementManager.FinalizeFocusManagement(this);
}
}
```