Hi
I am having great problems trying to implement a copy and paste feature for a WPF diagramming custom object.
[Serializable] internal class TranslateFunctionNode : FunctionNode { ... public override DiagramItem Clone(bool clipboard) { DiagramItem item = base.Clone(clipboard);
return item; //return base.Clone(clipboard); } protected override void SaveToXml(System.Xml.XmlElement xmlElement, XmlPersistContext context) { base.SaveToXml(xmlElement, context);
context.WriteString(FunctionName, ElementFunctionName, xmlElement); context.WriteInt(TemplateID, ElementTemplateID, xmlElement); context.WriteString(TemplateName, ElementTemplateName, xmlElement); }
protected override void LoadFromXml(System.Xml.XmlElement xmlElement, XmlPersistContext context) { base.LoadFromXml(xmlElement, context);
FunctionName = context.ReadString(ElementFunctionName, xmlElement); TemplateID = context.ReadInt(ElementTemplateID, xmlElement); TemplateName = context.ReadString(ElementTemplateName, xmlElement);
Description = CreateDescription(TemplateID, TemplateName); } ...
[Serializable] public abstract class FunctionNode : TemplatedNode {
I have tried calling CopySelection and PasteSelection and CopyToClipboard/PasteFromClipboard methods but none seem to work. No exceptions are raised but the clone method returns null and the SaveToXML method is not called on copy.
I have marked all classes as serializable and have called: Diagram.RegisterItemClass(typeof(FunctionNode), "FunctionNode", 0);
Diagram.RegisterItemClass(typeof(TranslateFunctionNode), "TranslationFunctionNode", 0);
in the Xaml.cs constructor.
Any ideas? Finding this very frustrating!!!
Thanks
Lee
|