/// <summary>
        /// Takes any LUCAWindowItems from the source window and places them in the target window
        /// </summary>
        /// <param name="target"></param>
        internal void MoveItems(LUCATabWindow target)
        {
            if (target == null) throw new ArgumentNullException("target");

            CurrentContent = null;

            while (Children.Any())
            {
                var i = Children.First();
                RemoveChild(i);
                target.AddChild(i);
            }
        }
        /// <summary>
        /// Attempts to restore a LUCATabItem into it's previous LUCATabWindow if that window is still viable.
        /// Otherwise a new LUCATabWindow is created and place into the LayoutContext with the previous LUCATabWindow
        /// Settings preserved. 
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public static LUCATabItem Restore(this LUCATabItem control)
        {
            if (control.PreviousContainerContext == null || control.PreviousContainerContext.ContainerContext.ContainerContext == null)
            {
                //restore the window into the layoutcontainer as a floating window
                var newWin = new LUCATabWindow
                                 {
                                     WindowID = Guid.NewGuid().ToString()
                                 };

                newWin
                    .AssignStoredWindowProperties(control)
                    .AddChild(control);

                newWin.LayoutContext = control.LayoutContext;

                newWin.Restore();
            }
            else
            {
                if (control.PreviousContainerContext.ContainerContext is LUCAStackPanel)
                {
                    var pc = control.PreviousContainerContext;
                    var newWin = new LUCATabWindow
                    {
                        WindowID = Guid.NewGuid().ToString()
                    };

                    newWin
                        .AssignStoredWindowProperties(control)
                        .AddChild(control);

                    newWin.LayoutContext = control.LayoutContext;

                    newWin.PreviousContainerContext = pc;

                    newWin.Restore();
                }
                else if (control.PreviousContainerContext.ContainerContext is LUCATabWindow)
                {
                    //restore the window to it's last known position
                    if (control.PreviousContainerContext.Index >
                        control.PreviousContainerContext.ContainerContext.Children.Count
                        || control.PreviousContainerContext.WasLastItemInContainer)
                    {
                        control.PreviousContainerContext.ContainerContext.AddChild(control);
                    }
                    else
                    {
                        control.PreviousContainerContext.ContainerContext.InsertChild(
                            control.PreviousContainerContext.Index, control);
                    }
                    return control;
                }
                else
                {
                    throw new LUCAControlException("Previous ContainerContext for LUCATabItem is not of expected Type");
                }
            }

            return control;
        }
        private void ChromeMouseLeave(object sender, MouseEventArgs e)
        {
            ClearDragEvents();

            if (!((LUCATabWindow)ContainerContext).AllowDetachFrom) return;

            //clone the old LUCATabWindow's column/row definitions
            var ocd = LUCAStackPanel.GetColumnDefinition(ContainerContext);
            var ocr = LUCAStackPanel.GetRowDefinition(ContainerContext);

            var newWin = new LUCATabWindow
            {
                WindowID = Guid.NewGuid().ToString()
            };

            if (ocd != default(ColumnDefinition))
            {
                var ncd = new ColumnDefinition { Width = ocd.Width };
                LUCAStackPanel.SetColumnDefinition(newWin, ncd);
            }

            if (ocr != default(RowDefinition))
            {
                var nrw = new RowDefinition { Height = ocr.Height };
                LUCAStackPanel.SetRowDefinition(newWin, nrw);
            }

            this.Remove();

            newWin.AddChild(this);
            newWin.AddAndDrag(LayoutContext);
        }