Looking through the source code, it appears as though LayoutAnchorable.Close() & LayoutDocument.Close() are executed, but inside these functions, __this.Root.Manager is null__.
Am I missing an extra step somewhere?
Comments: ** Comment from web user: BoucherS **
Hi,
This bug will be fixed in v2.3.
In the meantime, here's a solution :
1) In Xceed.Wpf.AvalonDock/Layout/LayoutDocument.cs, remove the "Close()" method and replace it with a new Close() method and a new CloseDocument() method :
```
public override void Close()
{
if( ( this.Root != null ) && ( this.Root.Manager != null ) )
{
var dockingManager = this.Root.Manager;
dockingManager._ExecuteCloseCommand( this );
}
else
{
this.CloseDocument();
}
}
internal bool CloseDocument()
{
if( this.TestCanClose() )
{
this.CloseInternal();
return true;
}
return false;
}
```
2) In Xceed.Wpf.AvalonDock/Layout/LayoutAnchorable.cs, remove the "Close()" method and replace it with a new Close() method and a new CloseAnchorable() method :
```
public override void Close()
{
this.CloseAnchorable();
}
internal void CloseAnchorable()
{
if( this.TestCanClose() )
{
if( this.IsAutoHidden )
this.ToggleAutoHide();
this.CloseInternal();
}
}
```
3) In Xceed.Wpf.AvalonDock/DockingManager.cs, Replace the content of method "_ExecuteCloseCommand(LayoutDocument document)" with this :
```
if (DocumentClosing != null)
{
var evargs = new DocumentClosingEventArgs(document);
DocumentClosing(this, evargs);
if (evargs.Cancel)
return;
}
if( document.CloseDocument() )
{
if( DocumentClosed != null )
{
var evargs = new DocumentClosedEventArgs( document );
DocumentClosed( this, evargs );
}
}
```
4) In Xceed.Wpf.AvalonDock/DockingManager.cs, Replace the content of method "_ExecuteCloseCommand(LayoutAnchorable anchorable))" with this :
```
var model = anchorable as LayoutAnchorable;
if (model != null )
{
model.CloseAnchorable();
}
```