Is it possible to use xamDiagram to allow user building a workflow (starting with root node and each node can create a node which is allowed from parent node - not all types of node can be created from all nodes) each node correspond to a view/viewmodel and by double clicking node it renders the view based on an instance of data model?
Hello,
I recommend reviewing the following example on how to bind the XamDiagram to complex objects and user interatction here:
eg.http://ko.infragistics.com/samples/wpf/diagram/binding-nodes-with-objects
You can allow your end users to expand upon the diagram by adding their own conection points and nodes via the XamDiagramToolbox compoent:
eg.http://ko.infragistics.com/samples/wpf/diagram/diagram-toolbox
Let me know if you have any specific quesitons regarding this matter.
I have reviewed it, this gives just a base. Interactivity is missing from your example links.
Essentially, I would like each node to create an allowed (pre-defined) node via either toolbox or context menu. just as an example look at following picture. So the toolbox should refresh when I change the selection of node or through context menu user is only able to add a node which is allowed
Hello Abs,
Thank you for following up. The XamDiagram exposes a SelectionChanged event that I recommend using to achieve your requirement since there is no direct behavior built-in to create your own category and shapes to reflect the selection made by the end user. Before getting started please note that the following items will be utilized when configuring your own toolbox category:
1. The ViewModel/Model that contains properties represented from each diagram node. 2. A new DiagramToolboxCategoryCollection3. A new DiagramTooloxCategory 4. DiagramToolboxItem5. DiagramNode
Keep in mind that by default you can select more than one diagram node at a time. Depending on your requirement this may block you from achieving your requirement. Therefore you can set the XamDiagram's SelectionMode property to Single for the end users.
Inside the SelectionChanged event you will need a new DiagramToolCategoryCollection and added to the XamDiagram's CustomCategories collection. Then you will a unique DiagramToolboxCategory based on which type of diagram node was selected. Having access to your model will be useful. You can write logic around your Model's properties and depending on their value you can add the correct category to the toolbox. When creating DiagramNodes you can utilize the System.Windows.Media.PathGeometry when constructing a custom shape and add it to the diagram node's Geogmetry property. And if you were to use a context menu I recommend showing a regular window with the toolbox in the same manner.
Please review my sample attached below for an example on getting started with custom categories. Let me know if you have any quesitons.
Assumption to have single node as selection mode works fine for this scenario, this is helpful sample to see how toolbox can change with selection of nodes.
However do you have an existing sample where toolbox is also fully bound to different types of object in viewmodel and dragging a node from it creates an "automatic" connection with selected node - viewmodel reflects this by adding this object to parent object (previously selected node). For the sake of simplicity nodes in toolbox take geometry of square/rectangle only and system creates directional arrow from parent to child (newly dragged node).
We do not have a sample that demonstrates what you are looking for. The existing samples use the toolbox as an extension to utilize it's core functionality and how to create custom categories. I can direct you to our conconsulting services department if you require more assistance with this matter.
If you were to work with our Consulting Services team, by visiting http://ko.infragistics.com/consulting/ , Infragistics Developer Support would remain involved with your inquiry and project to insure that control issues\questions are handled by DSEs, allowing our consultants to focus on the more complex functionality of the requirement.
If you have any additional questions please feel free to ask.
So even the example you mentioned earlier: http://ko.infragistics.com/samples/wpf/diagram/binding-nodes-with-objects can that not be modified so that more nodes are added from toolbox or context menu and these nodes are connected to existing node and reflected in viewmodel?
If not, what are the workarounds/suggestions?
I have clicked on the link you provided and I am lost there not sure what to do?
I am following up to provide you with a sample that demonstrates how to add a connection based on a selected DiagramNode.
The instructions are as followed:
1. Click on either the Mother or Father node2. Expand the toobox to find the third category with the unmarked DiagramConnection3. Drag the DiagramConnection to the XamDiagram and drop it anywhere.
The connection will automatically be added to the middle and selected nodes specified. This same logic can be used to add DiagramNodes. From here you can add the objects to your view model manually.
Let me know if you have any questions regarding this matter.
Thank you for following up. The XamDiagram component has an ItemsAdded and ItemsRemoved event as well as a ConnectionConnected event. The ItemsAdded event will occur immediately dropping a new DiagramNode from the toolbox. And the ConnectionConnected event will occur when a DiagramConnection is attached to a DiagramNode's DiagrramConnectionPoint.
I tried to programmatically attach a new DiagramConnection with a selected DiagramNode within the ItemsAdded event and add the objects to your DataContext from within the ConnectionConnected event.
However I ran into issues attaching the start position for the connection to a predefined DiagramConnectionPoint that is exposed on a DiagramNode.
I am currently investigating a viable approach to your solution with my team. Let me know if you have any questions regarding this matter.
Lets assume you have family tree construction scenario which has persons in toolbox (grand father, grand mother, father, mother, son, daughter, uncle, aunt and so on...)
Which link are you having issues with?
There is no way to automatically attach shapes and connectors to ones already added and bound to the XamDiagram control. How would you know which node to connect to? Can you please clarify this requirement with a demonstration?
Keep in mind that the most recent link I provided was to point to you to our Enterprise Development team since implementing this is out of scope for developer support.
Let me know if you have any quesitons regarding this matter.