One of the most common tasks when using the component is iterating over all items in the diagram document or navigating through the connections between items - from a node to the incoming or outgoing links, or from a link to its origin and destination nodes. To enumerate items of a diagram use the Items, Links or Nodes collections. The nodes that a link connects are referenced by the link's Destination and Origin properties. To access the links that are connected to a node, use its IncomingLinks and OutgoingLinks collections. The first collection contains references to all links pointing to the node, the second - to the links that start from it. Links can connect to rows of a table; to find such links use table's Rows collection and the IncomingLinks and OutgoingLinks collections.
If only one item is selected, it is considered the active item and can be accessed with the ActiveItem property. The type of this property is DiagramItem; you can get the actual type of the selected item through WinUI 3 reflection. Multiple items can be selected when clicking or dragging with the CTRL key pressed at the same time. Multiple-selection is represented by the Selection property of the Diagram class. The Selection object provides collections to access the selected Links and Nodes.
You can search for diagram items by their Id using the FindLinkById and FindNodeById methods. Id objects are compared by calling the Equals method of the System.Object class. Thus if the ids are of value type, they are compared by value (that is bitwise equality). If they are of reference type their Equals method is used. If there are more items with the same id, the first one will be returned. If no item with the specified id exists, a null reference (Nothing in Visual Basic) will be returned.