private static void OnItemSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DockingAdapterMVVM instance = (DockingAdapterMVVM)d;

            if (instance != null)
            {
                if (e.OldValue != null)
                {
                    var oldcollection = e.OldValue as INotifyCollectionChanged;
                    oldcollection.CollectionChanged -= instance.CollectionChanged;
                }
                if (e.NewValue != null)
                {
                    var newcollection = e.NewValue as INotifyCollectionChanged;
                    foreach (var item in ((IList)e.NewValue))
                    {
                        if (item is IChildrenElement)
                        {
                            instance.CreateChildren(item as IChildrenElement, instance);
                        }
                    }
                    newcollection.CollectionChanged += instance.CollectionChanged;
                }
            }
        }
        private void CreateChildren(IChildrenElement element, DockingAdapterMVVM adapter)
        {
            ContentControl control = new ContentControl()
            {
                Content = element
            };

            control.Name = element.Name;

            adapter.SetCanAutoHide(control as DependencyObject, element);
            adapter.SetCanClose(control as DependencyObject, element);
            adapter.SetCanDock(control as DependencyObject, element);
            adapter.SetCanDocument(control as DependencyObject, element);
            adapter.SetCanDrag(control as DependencyObject, element);
            adapter.SetCanFloat(control as DependencyObject, element);
            adapter.SetDesiredHeightInDockedMode(control as DependencyObject, element);
            adapter.SetDesiredWidthInDockedMode(control as DependencyObject, element);
            adapter.SetDockAbility(control as DependencyObject, element);
            adapter.SetDockToFill(control as DependencyObject, element);
            adapter.SetHeader(control as DependencyObject, element);
            adapter.SetNoDock(control as DependencyObject, element);
            adapter.SetNoHeader(control as DependencyObject, element);
            adapter.SetSideInDockedMode(control as DependencyObject, element);
            adapter.SetSideInFloatMode(control as DependencyObject, element);
            adapter.SetState(control as DependencyObject, element);
            adapter.SetTargetNameInDockedMode(control as DependencyObject, element);
            adapter.SetTargetNameInFloatMode(control as DependencyObject, element);

            adapter.PART_DockingManager.Children.Add(control);
        }
        private static void OnUseDocumentContainerChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            DockingAdapterMVVM adapter = sender as DockingAdapterMVVM;

            if (adapter != null)
            {
                adapter.PART_DockingManager.UseDocumentContainer = (bool)args.NewValue;
            }
        }