Category / Section
How to override cloning of symbols?
1 min read
By default, when a symbol is dragged and dropped from symbol palette, a clone of the symbol is created using XamlWriter and XamlReader. There are some disadvantages on using Xaml Reader/Writer:
- As reflection is used, more time is taken to clone.
- For more information, refer the following link: http://msdn.microsoft.com/en-us/library/ms754193(v=vs.110).aspx
This cloning of symbols is overridden in application level and it gives full control on the object to be cloned. Refer the following code example on how to return a connector as a clone of symbol.
C#
//Class derived from SymbolPaletteItem to override CloneContent method public class CustomSymbol : SymbolPaletteItem { public ConstomSymbol() { } public override object CloneContent() { LineConnector connector = new LineConnector(); connector.StartPointPosition = new Point(300, 500); connector.EndPointPosition = new Point(300, 700); return connector; } }
diagramControl - refers to the instance of DiagramControl.
Note: This code shows how to override cloning of symbols, for further details on how to add this symbol in palette, refer the online help documentation.