Hi Chris Goodwin,
Internal behavior:
When the symbol is dropped from the SymbolPalette, the Content of the Symbol is serialized. In DiagramView OnDrop event, this serialized object will be desterilized to create a clone of SymbolPaletteItem’s Content. Next a new node will be created and the cloned object will be set as a Node’s content.
Determine
which node is dropped:
To identify which Symbol has been dropped, Name property of the
SymbolPaletteItem can be used to achieve this requirement. SymbolPaletteItemName
property in NodeDrop event returns the Name of the dropped SymbolPaletteItem.
We have provided a code snippet to represent this ,please refer to the code
snippet.
Code Snippet:
//Creating SymbolPaletteItem
SymbolPaletteItem item = new SymbolPaletteItem();
item.Width = 40;
item.Height = 20;
//Used for Identifying the Dropped Node
item.Name = 'shape1';
//spg1 is SymbolPalette group
spg1.Items.Add(item);
//Register the NodeDrop event of DiagramView
diagramView.NodeDrop += new NodeDroppedEventHandler(diagramView_NodeDrop);
//DiagramView
NodeDrop Event
void diagramView_NodeDrop(object sender, NodeDroppedRoutedEventArgs evtArgs)
{
if (evtArgs.SymbolPaletteItemName == 'shape1')
{
//Reference of the Dropped Node using evtArgs
Node dropNode = evtArgs.DroppedNode as Node;
}
}
Please let us know if you have any concerns
Regards,
MohanaPriya R
Hi Chase Novack,
Regarding “Access the Tag or Name property of a SymbolPaletteItem inside the NodeClick event” To identify which Symbol has been dropped, Your requirement can be achieved by using NodeDrop event of DiagramView and Tag property of Node. Please use the Tag property of the Node to save the SymbolPaletteItemName property in NodeDrop Event. We have provided code snippet to achieve your requirement. Please refer to the following code snippet.
Code Snippet:
void diagramView_NodeDrop(object sender, NodeDroppedRoutedEventArgs evtArgs)
{
if (evtArgs.SymbolPaletteItemName == 'shape1')
{
//Reference of the Dropped Node using evtArgs
Node dropNode = evtArgs.DroppedNode as Node;
dropnode.Tag="shape1";
}
}
//DiagramView NodeClick Event
void diagramView_NodeClick(object sender, NodeRoutedEventArgs evtArgs)
{
Node dropnode = evtArgs.Node as Node;
//use the Tag property of Node to identify the Clicked Node
}
Please let us know if you have any concerns
Regards,
MohanaPriya R
Hi Chase,
Thanks for your update.
Please let us know if you require further assistance
on this.
Regards,
Saranya C