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

Get selected model item from diagram

Hi,
Using your 'Diagram Binding With TreeView' sample, which creates a diagram via data binding to objects inherited from ObservableCollection<>, please can you explain how to get the selected MODEL item?
I can access the selected view item via DiagramControl.View.SelectionList, but I cannot find out how to access the corresponding MODEL item, eg the ObjectTree class that is associated with the Node that I get from DiagramControl.View.SelectionList.

Many thanks,
James.

6 Replies

JR James Randle June 2, 2016 05:42 PM UTC

Essentially, what I am trying to do is create a custom ContextMenu for the Nodes in a diagram, that is dynamically populated when it is shown.
In order to do decide what items to add to the menu before it is shown, I need to know what the underlying MODEL object is, so that i can inspect its properties.

So if you could extend the 'Diagram Binding With TreeView' sample so I can right click a node, click on a menu item, and display a property of the corresponding MODEL object, that would be amazing, and very useful for other people too!

James.


JR James Randle June 2, 2016 05:52 PM UTC

In fact, please can you tell me how to do this for both DiagramControl, and the newer SfDiagram?

Thanks!
James.


JR James Randle June 2, 2016 09:18 PM UTC

Also, I just tried the SfDiagram example on the following page, and it doesn't work.
https://www.syncfusion.com/forums/119563/sfdiagram-vs-diagramcontrol

I get the following errors:
Error    224    Type 'DirectedTreeLayout' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter. 
Error    212    The type "DirectedTreeLayout" does not include any accessible constructors.
Error    223    The type 'syncfusion:LayoutManager' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

I have the following references added ...


Please help!
James.


SS Suresh Shanmugam Syncfusion Team June 6, 2016 12:32 PM UTC

Hi James Randle,

Thanks for using Syncfusion Products.

We have prepared the sample based on to get the selected model item from SfDiagram. Please find the sample in the following location.

Regards,
Suresh Shanmugam

Attachment: Get_Selected_ModelItem_b7f64a9.zip


JR James Randle June 6, 2016 02:44 PM UTC

Hi Suresh,
Thanks for your reply.

Can I have an example for the DiagramControl (classic) please.

Many thanks,
James.


RA Ranjitha Amirthalingam Syncfusion Team June 8, 2016 12:52 PM UTC

Hi James, 
 
We have provided sample to get the selected model item from Diagram Control (Classic) . Please refer to the sample from the following link. 
 
Sample Link: Classic_Sample
 
 
 
 
Regards, 
Ranjitha A. 


Loader.
Live Chat Icon For mobile
Up arrow icon