When I drag a docking window I sometimes get the following error from the Actipro Framework.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Cannot modify the logical children for this node at this time because a tree walk is in progress.
at System.Windows.FrameworkElement.RemoveLogicalChild(Object child)
at MS.Internal.Controls.InnerItemCollectionView.ClearModelParent(Object item)
at MS.Internal.Controls.InnerItemCollectionView._RemoveAt(Int32 index, Int32 indexR, Object item)
at System.Windows.Controls.ItemCollection.RemoveAt(Int32 removeIndex)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Replace(DependencyObject control, DependencyObject target, Boolean resetFocus)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Replace(DependencyObject control, DependencyObject target)
at ActiproSoftware.Windows.Controls.Docking.DockSite.ExtractDockingWindow(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.ExtractVisualContent(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.RemoveFromDockInDockingWindowContainer(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.RemoveFromDock(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.RemoveCore(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.RestoreToDocked(DependencyObject control, #ki notifier, Direction defaultDock, IList'1 windows)
at ActiproSoftware.Windows.Controls.Docking.DockSite.RestoreToDocked(DependencyObject control, #ki notifier, Direction defaultDock)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Restore(DependencyObject control, Direction defaultDock, Nullable'1 hintState)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Restore(DependencyObject control)
at ActiproSoftware.Windows.Controls.Docking.DockSite.Open(DockingWindow window, Boolean activate, Boolean focus)
at ActiproSoftware.Windows.Controls.Docking.DockingWindow.Open()
at MAT.Atlas.Host.Views.PageView.<>c__DisplayClass8_0.<HandlePageDockSiteWindowRegistered>b__0() in C:\dev\ATLAS10\MAT.Atlas.Host\Views\PageView.xaml.cs:line 93
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at MAT.Atlas.Host.Views.PageView.HandlePageDockSiteWindowRegistered(Object sender, DockingWindowEventArgs eventArgs) in C:\dev\ATLAS10\MAT.Atlas.Host\Views\PageView.xaml.cs:line 91
The actual lines of code executed are:
private void HandlePageDockSiteWindowRegistered(object sender, DockingWindowEventArgs eventArgs)
{
var dockingWindow = eventArgs.Window as ToolWindow;
if (dockingWindow == null)
{
return;
}
dockingWindow.Open(); <<<<< FAILS HERE
dockingWindow.Activate(true);
}
Does anyone have any ideas why this works sometimes and not others?