public List <DesignerContainer> DeserializeDesignerItems(XElement root)// 从xml文件解析图元
        {
            //CommandOpen.Run(CommManager, root);
            Dictionary <Guid, DesignerContainer> items = new Dictionary <Guid, DesignerContainer>();

            IEnumerable <XElement> itemsXml = root.Elements("DesignerContainers").Elements();

            foreach (XElement itemXml in itemsXml)
            {
                #region xml

                /*
                 * <DesignerElement Version="1.0" Type="Wss.Foundation.Controls.DesignerContainer, Wss.Foundation">
                 * <Name>换热器</Name>
                 * <Canvas.Left>522</Canvas.Left>
                 * <Canvas.Top>257</Canvas.Top>
                 * <Width>142</Width>
                 * <Height>200</Height>
                 * <Panel.ZIndex>20</Panel.ZIndex>
                 * <ItemOpacity>1</ItemOpacity>
                 * <LockDesign>False</LockDesign>
                 * <WindowTip>False</WindowTip>
                 * <NameVisible>True</NameVisible>
                 * <NamePosition></NamePosition>
                 * <Angle>0</Angle>
                 * <BaseContainer.ScaleX>1</BaseContainer.ScaleX>
                 * <BaseContainer.ScaleY>1</BaseContainer.ScaleY>
                 * <BaseContainer.ID>ba33c2e8-f1d9-4d37-9d54-4d7a4800d720</BaseContainer.ID>
                 * <BaseContainer.ParentID>00000000-0000-0000-0000-000000000000</BaseContainer.ParentID>
                 * <BaseContainer.IsGroup>False</BaseContainer.IsGroup>
                 * <DesignerElement Version="1.0" Type="Common.Package.HeatExchanger, Common.Package" />
                 * </DesignerElement>
                 */
                #endregion
                DesignerContainer item = DesignAttributeService.DeSerializFromXElement(itemXml) as DesignerContainer; // itemXml.ToDesignerContainer(); //从xml序列化成控件
                Add(item);                                                                                            //item.Content有值的
                if (!items.ContainsKey(item.ID))
                {
                    items.Add(item.ID, item);
                    PropertyInfo[] ps = item.Content.GetType().GetProperties();

                    item.IsHitTestVisible  = !(GetZIndex(item).Equals(int.MinValue));
                    item.Focusable         = item.IsHitTestVisible;
                    item.IsEnabled         = item.IsHitTestVisible;
                    item.IsSelected        = false;
                    item.PreviewMouseMove += Item_PreviewMouseMove;
                }
            }
            //InvalidateVisual();
            return(items.Values.ToList());
        }
        //将XElement节点转换为一组DesignerItem
        public static List <DesignerContainer> ToDesignerContainers(this XElement xElement)
        {
            var result = new List <DesignerContainer>();

            if (xElement == null)
            {
                return(result);
            }
            var items = xElement.Elements();

            result.AddRange(items.Select(item =>
                                         DesignAttributeService.DeSerializFromXElement(item) as DesignerContainer
                                         ).Where(ditem => ditem != null));
            return(result);
        }
 //将XElement节点转换为DesignerItem实例,对于结构不符合的节点,将返回null
 public static DesignerContainer ToDesignerContainer(this XElement xElement)
 {
     return(DesignAttributeService.DeSerializFromXElement(xElement) as DesignerContainer);
 }