Browse Source

Merge cce1501319 into 64115bab16

pull/1677/merge
billw2012 4 years ago
committed by GitHub
parent
commit
7f31f20e7a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit.LiveExplorer/CodeFiles/PropertyGridDefaultEditorsView.xaml.cs.txt
  2. 8
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit.LiveExplorer/Samples/PropertyGrid/Views/PropertyGridDefaultEditorsView.xaml.cs
  3. 30
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControl.cs

8
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit.LiveExplorer/CodeFiles/PropertyGridDefaultEditorsView.xaml.cs.txt

@ -171,9 +171,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 };
}
}
}
}

8
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit.LiveExplorer/Samples/PropertyGrid/Views/PropertyGridDefaultEditorsView.xaml.cs

@ -171,9 +171,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 };
}
}
}
}

30
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControl.cs

@ -539,20 +539,28 @@ namespace Xceed.Wpf.Toolkit
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 )

Loading…
Cancel
Save