I'm able to consistently reproduce an exception via a series of pinning/unpinning toolboxes in a docking application, & switching the theme. I'm assuming you'll probably want a repro solution, but since it takes me a fair bit of time to trim out all the company's proprietary code & simplify things down, I just thought I'd post the info here first, in hopes that it turns out to be an "obvious" issue. first, the full exception:
System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.AddLogicalChild(Object child)
at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement element)
at System.Windows.Controls.UIElementCollection.Insert(Int32 index, UIElement element)
at ActiproSoftware.Windows.Controls.Docking.Primitives.AutoHidePopupPanel.set_ToolWindowContainer(ToolWindowContainer #Ld)
at ActiproSoftware.Windows.Controls.Docking.DockHost.OpenAutoHidePopup(ToolWindow toolWindow)
at ActiproSoftware.Windows.Controls.Docking.Logic.LayoutChangeProcessor.BringToFront(DockingWindow #sb, Boolean #an)
at ActiproSoftware.Windows.Controls.Docking.Logic.LayoutChangeProcessor.Activate(DockingWindow #sb, Boolean #an)
at ActiproSoftware.Windows.Controls.Docking.DockingWindow.Activate(Boolean focus)
at ActiproSoftware.Windows.Controls.Docking.Logic.AutoHidePointerProcessor.#1Gj(Object #xhb, Object #yhb)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Here are the exact steps that consistently makes it happen: https://www.screencast.com/t/iFmxyRgnT
1) Unpin the tool container
2) Expand the tool container & set a different theme (this is bound to a property in which the setter assigns ThemeManager.CurrentTheme = value.ToString();)
3) Click on the tool container's tab to expand it again. Exception happens. (Sometimes it happens when just hovering over the tool container's tab, without needing to click).
Cheers,
J~