Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,15 @@ namespace Xceed.Wpf.Toolkit.LiveExplorer.Samples.PropertyGrid.Views
public Person Person { get; set; }
}

public class Person
public class Person : ICloneable
{
[ReadOnly(true)]
public Guid UniqueID { get; set; } = Guid.NewGuid();
public string Name { get; set; }
public object Clone()
{
return new Person { Name = Name };
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,15 @@ public Collection<Person> CollectionOfPerson
public Person Person { get; set; }
}

public class Person
public class Person : ICloneable
{
[ReadOnly(true)]
public Guid UniqueID { get; set; } = Guid.NewGuid();
public string Name { get; set; }
public object Clone()
{
return new Person { Name = Name };
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -539,20 +539,28 @@ private object DuplicateItem( ExecutedRoutedEventArgs e )

var baseItem = e.Parameter;
var newItemType = baseItem.GetType();
var newItem = this.CreateNewItem( newItemType );

var type = newItemType;
while( type != null )
if (typeof(ICloneable).IsAssignableFrom(newItemType))
{
var baseProperties = type.GetFields( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
foreach( var prop in baseProperties )
{
prop.SetValue( newItem, prop.GetValue( baseItem ) );
}
type = type.BaseType;
return ((ICloneable) baseItem).Clone();
}
else
{
var newItem = this.CreateNewItem(newItemType);

return newItem;
var type = newItemType;
while (type != null)
{
var baseProperties = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
foreach (var prop in baseProperties)
{
prop.SetValue(newItem, prop.GetValue(baseItem));
}

type = type.BaseType;
}

return newItem;
}
}

private void MoveDown( object sender, ExecutedRoutedEventArgs e )
Expand Down