MindFusion.Wpf Pack Programmer's Guide
Attaching and Grouping Items

Diagramming for WPF allows attaching a node to another diagram element, establishing a subordinate - master relationship between the two items. The easiest way to attach nodes is to call the AttachTo method. When a master element is moved or resized, any subordinated node follows it, so that the initial distance between the two items stays constant. This happens both when a user moves the master item around, and when the item position is changed using a method or a property.

Possible Uses

Hierarchical Grouping

A unit of attached items is represented by an instance of the Group class. To create a group, instantiate a Group object and add it to the diagram's Groups collection, or call the CreateGroup method passing the master object as argument. Attach items to the group using the various Group methods. The AttachTo method of nodes is a shortcut to creating a group and attaching an item to it.

Every member of a group can be the master item of another group, that is an item can be subordinate in one group and meanwhile be another group's master. Diagramming for WPF doesn't impose any limits to the depth and width of group hierarchies built that way. However, it is not possible to put an item as a subordinate in more than one groups because the hierarchy relations would become ambiguous.

Unions

It is possible to create such groups, that if any item in the hierarchy is modified, all other items are updated too. This can be done by putting the items in circular chain of dependencies - that is item1 is attached to item2, item2 to item3 ... itemN to item1. If any of these items is modified, the change will propagate through the chain until it reaches its originator.

Attaching Items to a Group

Links cannot be attached to groups but can be master items of groups. If a group's master item is a link, nodes can be attached to the control points or segments of the link. See the AttachToLinkPoint and AttachToLinkSegment methods for details. If the master item is a node, other nodes can be attached to any of its corners, or to an area specified as percent of master-node's bounding rectangle. Check AttachToCorner and AttachProportional for details. A shortcut to creating Group instance and calling the appropriate AttachTo* methods is provided by the AttachTo method of the DiagramNode class.

Accessing Group Items

Group members can be accessed using the MainItem property and the AttachedNodes collection. To get the groups in which an item participates, use its MasterGroup and SubordinateGroup properties.

Destroying Groups

If a user deletes the master item of a group, the group is destroyed automatically and the GroupDestroyed event is raised. If AutoDeleteItems is enabled, subordinated items in the group are deleted too. If AutoDeleteItems is disabled, subordinated items are just detached from their master and remain intact. Groups can be destroyed programmatically by removing them from the diagram's Groups collection.