//将List<DesignerContainer>转换为XElement节点
        public static XElement ToXElement(this IEnumerable <DesignerContainer> obj)
        {
            var result = new XElement("DesignerContainers");

            if (obj == null)
            {
                return(result);
            }
            foreach (var item in obj)
            {
                result.Add(DesignAttributeService.SerializToXElement(item));
            }
            return(result);
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                _dragStartPoint = null;
            }

            if (!_dragStartPoint.HasValue)
            {
                return;
            }
            var di = Content as DesignerItem;

            if (di != null)
            {
                var dcontainer = new DesignerContainer();
                dcontainer.Content = di;
                var panel = VisualTreeHelper.GetParent(this) as WrapPanel;

                var dataObject = new DragObject();
                dataObject.Xaml = DesignAttributeService.SerializToXElement(dcontainer).ToString();

                if (panel != null)
                {
                    // desired size for DesignerCanvas is the stretched Toolbox Item size
                    var scale = 1.0;
                    dataObject.DesiredSize = new Size(panel.ItemWidth * scale, panel.ItemHeight * scale);
                }

                DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Copy);
                #region  用
                //var dcontainer = new DesignerContainer();
                //dcontainer.Content = item;

                //WrapPanel panel = VisualTreeHelper.GetParent(this) as WrapPanel;
                //DragObject dataObject = new DragObject();
                //dataObject.Xaml= System.Windows.Markup.XamlWriter.Save(item);//dataObject.Xaml = DesignAttributeService.SerializToXElement(di).ToString();
                //if (panel != null)
                //{
                //    var scale = 1.0;
                //    dataObject.DesiredSize = new Size(panel.ItemWidth*scale, panel.ItemHeight*scale);
                //}

                ////DragDrop.DoDragDrop(this, di, DragDropEffects.Copy);
                //DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Copy);
                #endregion
            }
            e.Handled = true;
        }