This bug is inside AvalonDock within the Xceed Extended WPF Toolkit version 2.2.1:
Closing a LayoutAnchorable that is docked inside a LayoutDocumentPane causes an infinite loop, resulting in a StackOverflowException.
Looking at the call stack, it looks like LayoutAnchorable.Close() results in an event triggered in the docking manager, which in turn calls LayoutAnchorable.Close() forever looping:
```
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutElement.Root.get()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
//// ... and so on
```
I have attached a small sample app which demonstrates this bug. In it, we have a WPF app with a LayoutDocumentPane containing a LayoutDocument ("Document") and a LayoutAnchorable ("Close Me"). Upon closing the "Document", the app behaves as expected. Upon closing the "Close Me" tab, the StackoverFlowException bug occurs.
Closing a LayoutAnchorable that is docked inside a LayoutDocumentPane causes an infinite loop, resulting in a StackOverflowException.
Looking at the call stack, it looks like LayoutAnchorable.Close() results in an event triggered in the docking manager, which in turn calls LayoutAnchorable.Close() forever looping:
```
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutElement.Root.get()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
//// ... and so on
```
I have attached a small sample app which demonstrates this bug. In it, we have a WPF app with a LayoutDocumentPane containing a LayoutDocument ("Document") and a LayoutAnchorable ("Close Me"). Upon closing the "Document", the app behaves as expected. Upon closing the "Close Me" tab, the StackoverFlowException bug occurs.