public DevicesToolBoxViewModel() { string devicesXml = Assembly.GetExecutingAssembly().Location + @"\..\" + Constants.DEVICES_FILE; if (File.Exists(devicesXml)) { DeviceCollection dc = (DeviceCollection)XmlSerializerUtil.LoadXml(typeof(DeviceCollection), devicesXml); DeviceItems = dc.DeviceItems; connectOperationParent(DeviceItems); } else { Device curtainDev = new Device(); curtainDev.Type = DeviceType.CURTAIN; Operation op1 = new Operation(); op1.Name = "开关"; op1.SetParent(curtainDev); curtainDev.OperationItems.Add(op1); DeviceItems.Add(curtainDev); Device fogDev = new Device(); fogDev.Type = DeviceType.FOG; DeviceItems.Add(fogDev); } }