When the built in Collection Editor loads an existed item in a collection, it tries to clone the item by copying all its fields to a new item, while the latter one will be edited in the editor. However, the Xceed.Wpf.Toolkit.CollectionControl.CopyValues method only copies the fields declared in the Type which the item to clone is, not with those in its base class(es).
Here is the revised implementation, feel free to use it if it helps.
```
private static void CopyValues(object source, object destination)
{
LinkedList<Type> types = new LinkedList<Type>();
var type = source.GetType();
while (type != null)
{
types.AddFirst(type);
type = type.BaseType;
}
foreach (var t in types)
{
FieldInfo[] myObjectFields = t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
foreach (FieldInfo fi in myObjectFields)
{
fi.SetValue(destination, fi.GetValue(source));
}
}
}
```
Comments: Duplicate of
https://wpftoolkit.codeplex.com/workitem/18206
This is fixed in version 2.0
Here is the revised implementation, feel free to use it if it helps.
```
private static void CopyValues(object source, object destination)
{
LinkedList<Type> types = new LinkedList<Type>();
var type = source.GetType();
while (type != null)
{
types.AddFirst(type);
type = type.BaseType;
}
foreach (var t in types)
{
FieldInfo[] myObjectFields = t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
foreach (FieldInfo fi in myObjectFields)
{
fi.SetValue(destination, fi.GetValue(source));
}
}
}
```
Comments: Duplicate of
https://wpftoolkit.codeplex.com/workitem/18206
This is fixed in version 2.0