We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to add a label to a SymbolPaletteItem in WPF?

How to add a label to a SymbolPaletteItem in WPF, when it's on the palette itself?


1 Reply

NA Nikhil A Syncfusion Team April 21, 2009 07:18 PM UTC

Hi Kevin,

Thanks for your interest in Syncfusion products.


A label can be added to the SymbolPaletteItem only as a content of the Item in the following way:

SymbolPaletteItem ss = new SymbolPaletteItem();
Label l = new Label();
l.Content = "Label";
ss.Content = l;

A SymbolpaletteItem can hold only one type of content at a time. We currently do not have any Label property for the SymbolPaletteItem as we have for the Nodes.This has been confirmed as a Feature Request. We will implement this feature in our forthcoming new version releases or service pack releases. We usually have an interval of at least three months between releases. The feature implementationwould also greatly depend on the factors such as product design, code compatibility and complexity. We will provide a Label property for the Item so that apart from the content being hosted you can also provide a label.

In our upcoming release(Volume 2) of EssentialDiagram which is scheduled to be in the next week, we have provided the support to identify the nodes being dropped on the page. The Name property of the SymbolPaletteItem can be used to identify the dropped node in the NodeDrop event as it becomes the name of the node on the page. This is particularly useful when you have to identify the item which was dropped and perform some operation on the node before it gets added to the page. So in this case, the SymbolPaletteItem's content can be assigned as the label of the node on the page in the following way:

A name can be assigned to the item. This name becomes the name of the dropped node.


SymbolPaletteItem ss = new SymbolPaletteItem();
Label l = new Label();
l.Content = "Label";
ss.Content = l;
ss.Name="MyItem";


The NodeDrop event can be declared:

diagramView.NodeDrop += new NodeDroppedEventHandler(diagramView_NodeDrop);


Event Handler:

void diagramView_NodeDrop(object sender, NodeDroppedRoutedEventArgs evtArgs)
{
if(evtArgs.DroppedNode.Name=="MyItem")
{

evtArgs.DroppedNode.Label = (evtArgs.DroppedNode.Content as Label).Content.ToString();

}

}

In this way identifying an item based on its name allows the user to change the content or perform any operation on the node before it gets added to the page.

Please let us know if you have any queries or concerns.

Regards,
Nikhil.




Loader.
Live Chat Icon For mobile
Up arrow icon