public void UpdateFromXmlItem(XmlItem xmlItem) { var oldTypeId = Xml.ID; Xml = xmlItem; Name = xmlItem.Name; TypeID = xmlItem.ID; if (xmlItem != XmlItem.Empty) { SetValue("version", 1); /* update the name as well */ Name = xmlItem.Name; if (null != xmlItem.LongName && xmlItem.LongName.Length > 0) { LongName = xmlItem.LongName; } if (null != xmlItem.Tooltip && xmlItem.Tooltip.Length > 0) { Tooltip = xmlItem.Tooltip; } /* Update all extra fields with fields from the xml. */ if (xmlItem.GetFieldValueAsBool("hasRandomProperties")) { foreach (XmlObjectField field in xmlItem.Fields) { switch (field.Type.ToLower()) { case "bool": SetValue(field.Name, field.Value.StartsWith("t", true, null)); break; case "int": SetValue(field.Name, int.Parse(field.Value)); break; case "string": SetValue(field.Name, field.Value); break; default: //no match since we have no idea what type it is break; } } } /* SetValue("quantity", value); */ Quantity = xmlItem.Stack; } //update all items for is selected foreach (var group in AllGroups) { foreach (var item in group.Items) { item.NotifyIsSelectedChanged(); } } OnPropertyChanged("DisplayName"); OnPropertyChanged("QuantityDescription"); OnPropertyChanged("MaxQuantity"); //check if we have to reflow the inventory if (oldTypeId == XmlItem.Empty.ID || xmlItem.ID == XmlItem.Empty.ID) { _character.CleanupInventory(); _character.UpdateInventory(); } }