Ho già provato questa soluzione ma mi dà questo errore:
System.Runtime.Serialization.InvalidDataContractException : Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.
Ricciolo ha scritto:
Se intendi una clonazione dell'elemento la tecnica più veloce è affidarti alla semplice serializzazione e deserializzazione dell'oggetto usando il DataContractSerializer. Un po' come viene fatto qua http://www.winfxitalia.com/script/91/Clonare-Facilmente-Istanza-Classe.aspx ma con il BinaryFormatter (funzionamento simile).
Qeusto comporta però dei rischi. Non è detto che riesca a serializzare tutte le proprietà e sicuramente non di recupera le attached property.