private static void Float(Layout layout, DockItem dockItem)
        {
            var sourceOfDockItemsControl =
                dockItem.GetSelfAndLogicalAncestors().OfType <ItemsControl>().FirstOrDefault() as DockItemsControl;

            if (sourceOfDockItemsControl == null)
            {
                throw new ApplicationException("Unable to determine source items control.");
            }
            var sourceDockControl = DockControl.GetOwnerOfHeaderItems(sourceOfDockItemsControl);

            layout._floatTransfer = FloatTransfer.TakeSnapshot(dockItem, sourceDockControl);
            var floatingItemSnapShots = sourceDockControl.GetVisualDescendents().OfType <Layout>()
                                        .SelectMany(l => l.FloatingDockItems().Select(FloatingItemSnapShot.Take))
                                        .ToList();

            if (sourceDockControl == null)
            {
                throw new ApplicationException("Unable to determine source tab control.");
            }
            sourceDockControl.RemoveItem(dockItem);

            ((IList)layout.FloatingItems).Add(layout._floatTransfer.Content);

            Dispatcher.UIThread.InvokeAsync(
                new Action(() => RestoreFloatingItemSnapShots(layout, floatingItemSnapShots)), DispatcherPriority.Loaded);
        }
        private void PerpareFloatingContainerForItemOverride(Control control, object o)
        {
            var headeredDockItem = control as HeaderedDockItem;

            if (headeredDockItem == null)
            {
                return;
            }

            SetIsFloatingInLayout(control, true);

            var headBinding = new Binding {
                Path = FloatingItemHeaderMemberPath, Source = o
            };

            headeredDockItem.Bind(HeaderedDockItem.HeaderContentProperty, headBinding);

            if (!string.IsNullOrWhiteSpace(FloatingItemDisplayMemberPath))
            {
                var contentBinding = new Binding {
                    Path = FloatingItemDisplayMemberPath, Source = o
                };
                headeredDockItem.Bind(ContentControl.ContentProperty, contentBinding);
            }

            if (_floatTransfer == null || (o != _floatTransfer.Content && control != _floatTransfer.Content))
            {
                return;
            }

            var dockItem = (DockItem)control;

            Dispatcher.UIThread.InvokeAsync(new Action(() =>
            {
                dockItem.Measure(new Size(_floatingItems.Width, _floatingItems.Height));
                var newWidth  = Math.Min(_floatingItems.Width * .75, dockItem.DesiredSize.Width);
                var newHeight = Math.Min(_floatingItems.Height * .75, dockItem.DesiredSize.Height);
                dockItem.SetValue(DockItem.XProperty, _floatingItems.Width / 2 - newWidth / 2);
                dockItem.SetValue(DockItem.YProperty, _floatingItems.Height / 2 - newHeight / 2);
                dockItem.SetValue(WidthProperty, newWidth);
                dockItem.SetValue(HeightProperty, newHeight);
            }), DispatcherPriority.Loaded);

            _floatTransfer = null;
        }