Represents a diagram that generates its content by binding to external data sources.
Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf
SyntaxC#
Copy Code
|
|---|
public class DataBoundDiagram : Diagram |
Visual Basic
Copy Code
|
|---|
Public Class DataBoundDiagram |
RemarksDataBoundDiagram implements a model-view separation that allows you to display very large diagrams by binding them to external data sources. When hosted within a DiagramView, actual DiagramNode and DiagramLink instances are created only for the elements currently visible in the viewport. This keeps the WPF visual tree small and provides massive performance improvements when working with diagrams containing thousands of elements.
The data items to be displayed as nodes and links must be assigned to the NodesSource and LinksSource properties, respectively. The BindingMode property specifies whether changes made by the user, such as drawing new items or moving existing ones, should be synchronized back to your data source.
While virtualization is managed by the view control, DataBoundDiagram handles the efficient creation and recycling of items as they move in and out of the viewport. By default, it creates TemplatedNode and DiagramLink instances. You can customize this behavior by providing InstantiateNode and InstantiateLink callbacks. Conversely, when a user draws a new item, the diagram uses the InstantiateNodeData and InstantiateLinkData delegates to create the corresponding objects for your data source.
DataBoundDiagram assumes a standard data schema where node items expose X, Y, Width, and Height properties of type double. If dimensions are missing, the DefaultNodeSize is used. You can also provide custom positioning logic via the ResolveNodePosition delegate. Link data items must expose Origin and Destination properties that reference items within the NodesSource.
As a derivative of the Diagram class, DataBoundDiagram inherits all standard properties, methods, and events. You can specify default appearances and handle events like NodeClicked normally. However, keep in mind that the base Nodes and Links collections are dynamic; they contain only the diagram items that are currently "realized" and visible on screen.
When handling diagram events, use the GetDataItem method to retrieve the source data object associated with a specific diagram item. Similarly, you can call GetDiagramNode or GetDiagramLink to find the actual diagram item representing a specific data object, if it is currently being rendered.
Inheritance HierarchySystem.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.DataBoundDiagram
See Also