Implements virtualization of diagram elements.
Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf
C# Copy Code |
---|
public class VirtualizingDiagram : Diagram |
Visual Basic Copy Code |
---|
Public Class VirtualizingDiagram |
VirtualizingDiagram can display very large diagrams where there are actual DiagramNode and DiagramLink instances created only for the elements that should be currently shown on screen. This helps keeping the WPF visual tree small and could lead to huge performance improvements if there are thousands of elements in the diagram.
The data items that should be displayed as nodes must be assigned to the NodesSource property, and the data items that should be displayed as links must be assigned to the LinksSource property. The BindingMode property specifies whether the data source should be updated when the user draws new diagram items interactively.
When the diagram is displayed initially, or while the user scrolls it, VirtualizingDiagram automatically creates TemplatedNode and DiagramLink instances for the items that should be shown on screen. You can create diagram items of a different type via the InstantiateNode and InstantiateLink callbacks. Similarly when the user draws diagram items, the control calls the InstantiateNodeData and InstantiateLinkData delegates to create data items for the new diagram items.
VirtualizingDiagram assumes that node data items expose X and Y properties of type double specifying the node positions, and optional Width and Height properties specifying the node sizes. If Width and Height are not present, the nodes size is set to DefaultNodeSize. It is also possible to specify custom positions via the ResolveNodePosition delegate. Link data items must expose Origin and Destination properties that are references to items from NodesSource.
VirtualizingDiagram is a child class of Diagram and derives all of its properties and events. This lets you specify default appearance properties the usual way, and handle events such as NodeClicked to detect clicks over the visible items. Note that the base Nodes and Links collections will contain items only for the currently visible portion of the diagram.
When handling Diagram events raised for nodes and links, use the GetDataItem method to find out which item from the data source is associated with an actual diagram item. Vice versa, call GetDiagramNode and GetDiagramLink to find out the diagram item currently shown for a data item, if any.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
MindFusion.Diagramming.Wpf.DiagramBase
MindFusion.Diagramming.Wpf.Diagram
MindFusion.Diagramming.Wpf.VirtualizingDiagram