Implementing Syncfusion Blazor Diagram
A comprehensive skill for building interactive diagrams with the Syncfusion Blazor Diagram component — flowcharts, organizational charts, mind maps, BPMN process diagrams, UML sequence diagrams, network diagrams, and more.
When to Use This Skill
Use this skill when you need to:
- Create flowcharts, org charts, mind maps, or network diagrams in Blazor
- Work with
SfDiagramComponent, nodes, connectors, or shapes
- Configure automatic layouts (hierarchical, radial, mind map, org chart, flowchart)
- Implement BPMN process diagrams with BPMN shapes
- Build swimlane diagrams for process modeling
- Add symbol palettes for drag-and-drop diagram building
- Bind diagram data from a collection or remote source
- Implement diagram interactions (selection, drag, resize, zoom, pan)
- Export diagrams to PNG/JPEG/SVG or print them
- Serialize and restore diagram state (save/load)
- Enable collaborative real-time editing
- Add UML sequence diagrams
- Handle diagram events, annotations, and ports
Important: API Verification Required
API Verification Required: Always verify API class names, properties, and signatures by reading reference files (references/*.md) BEFORE generating code examples. Do not assume or infer class names.
⚠️ Before writing ANY code, review the Common Mistakes section directly below to avoid known invalid APIs and properties.
Quick Start
@using Syncfusion.Blazor.Diagram
<SfDiagramComponent Width="100%" Height="600px" Nodes="@nodes" Connectors="@connectors" />
@code {
DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>
{
new Node
{
ID = "node1", OffsetX = 150, OffsetY = 150,
Width = 100, Height = 50,
Style = new ShapeStyle { Fill = "#6BA5D7", StrokeColor = "white" },
Annotations = new DiagramObjectCollection<ShapeAnnotation>
{
new ShapeAnnotation { Content = "Start" }
}
}
};
DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>
{
new Connector { ID = "conn1", SourceID = "node1", TargetID = "node2" }
};
}
Common Patterns
| Goal |
Reference |
| First diagram setup |
references/getting-started.md |
| Add/configure nodes |
references/nodes.md |
| Add/configure connectors |
references/connectors.md |
| Use built-in shapes |
references/shapes.md |
| Add text labels |
references/annotations.md |
| Define connection points |
references/ports.md |
| Org charts / auto-layout |
references/layout.md |
| Swimlane diagrams |
references/swimlane.md |
| BPMN process diagrams |
references/bpmn.md |
| Drag-and-drop palette |
references/symbol-palette.md |
| Bind data to diagram |
references/data-binding.md |
| Selection, drag, zoom |
references/interaction.md |
| Handle diagram events |
references/events.md |
| Save and load diagrams |
references/serialization.md |
| Export / print |
references/export-print.md |
| CSS / theme styling |
references/styling.md |
| UML sequence diagrams |
references/uml-sequence.md |
| Real-time collaboration |
references/collaborative-editing.md |
| Context menu, tooltips, rulers, localization |
references/advanced-features.md |
| Miniature overview / bird's-eye navigation |
references/overview-component.md |
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- NuGet package installation (
Syncfusion.Blazor.Diagram)
- Service registration and namespace imports
- Setup for Blazor Server, WebAssembly, MAUI
- CSS/theme configuration
- Minimal working diagram example
Nodes
📄 Read: references/nodes.md
- Creating and configuring nodes
- Node types: basic, flow shape, path, image, HTML, native
- Node positioning, sizing, z-order
- Node style (fill, stroke, opacity)
- Expand/collapse children
- Node events and interaction
Connectors
📄 Read: references/connectors.md
- Creating connectors between nodes or free-floating
- Segment types: straight, orthogonal, bezier
- Multiple segments per connector
- Arrows, line style, and decoration
- Connector interaction (bend, drag endpoints)
- Connector events
Shapes
📄 Read: references/shapes.md
- Built-in basic shapes (rectangle, ellipse, triangle, etc.)
- Flow shapes (process, decision, terminator, etc.)
- Path shapes (custom SVG paths)
- Image and HTML content shapes
- Native SVG shapes
- Choosing the right shape type
Annotations
📄 Read: references/annotations.md
- Adding text labels to nodes and connectors
- Annotation positioning and alignment
- Font, color, and style customization
- Inline editing of annotations
- Multiple annotations per element
- Annotation interaction events
- Interaction constraints:
AnnotationConstraints flags, DragLimit (PathAnnotation)
- Hyperlinks with
Hyperlink (Url, Content, OpenMode)
- Events: SelectionChanging/Changed, PositionChanging/Changed, SizeChanging/Changed, RotationChanging/Changed, TextChanging/Changed
Ports
📄 Read: references/ports.md
- Connection ports (fixed connection points on nodes)
- Dynamic ports (created at runtime)
- Port positioning (relative and absolute)
- Port appearance and visibility
- Restricting connections to specific ports
Layout
📄 Read: references/layout.md
- Automatic layout overview and when to use each type
- Hierarchical tree layout (top-down, left-right)
- Organizational chart layout
- Mind map layout
- Radial tree layout
- Flowchart layout
- Force-directed tree layout
- Complex hierarchical layout
- Layout spacing, margin, and orientation settings
- Layout events and callbacks
await DoLayoutAsync() — refresh layout at runtime after adding/removing nodes
Swimlane
📄 Read: references/swimlane.md
- Creating swimlane diagrams
- Adding lanes and configuring lane properties
- Phase configuration (vertical/horizontal phases)
- Swimlane symbol palette integration
- Swimlane interactions
<SfDiagramComponent Height="600px" Swimlanes="@swimlanes" />
@code {
DiagramObjectCollection<Swimlane> swimlanes = new();
protected override void OnInitialized()
{
swimlanes.Add(new Swimlane
{
ID = "swimlane1",
OffsetX = 400, OffsetY = 300,
Width = 600, Height = 200,
Lanes = new DiagramObjectCollection<Lane>()
{
new Lane(){
Height = 100,
Header = new SwimlaneHeader(){
Width = 30,
Annotation = new ShapeAnnotation(){ Content = "Consumer" }
},
Children = new DiagramObjectCollection<Node>()
{
new Node(){Height = 50, Width = 50, LaneOffsetX = 250, LaneOffsetY = 30},
}
},
}
});
}
}
BPMN
📄 Read: references/bpmn.md
- BPMN shape types (events, activities, gateways, data)
- BPMN event types (start, end, intermediate, boundary)
- BPMN activity types (task, subprocess, call activity)
- BPMN gateway types (exclusive, parallel, inclusive, etc.)
- BPMN connectors (sequence flow, message flow, association)
- Data objects and data stores
- Expanded sub-process
- BPMN text annotation
// Exclusive gateway (XOR)
nodes.Add(new Node
{
ID = "gateway1", OffsetX = 300, OffsetY = 200, Width = 50, Height = 50,
Shape = new BpmnGateway
{
GatewayType = BpmnGatewayType.Exclusive
}
});
Symbol Palette
📄 Read: references/symbol-palette.md
- Setting up
SfSymbolPaletteComponent
- Defining palette groups and symbols
- Custom symbols and stencils
- Drag-and-drop from palette to diagram
- Palette search and customization
Data Binding
📄 Read: references/data-binding.md
- Binding diagram from a flat list or IEnumerable
- Hierarchical data binding (parent-child relationships)
- Remote data source integration
- Runtime CRUD:
await ReadDataAsync(query?), await InsertDataAsync(data), await UpdateDataAsync(keyField, data), await DeleteDataAsync(keyField, value)
await RefreshDataSourceAsync() — reload all data and rebuild layout
- Mapping data fields to node/connector properties
Interaction & Commands
📄 Read: references/interaction.md
- Selection:
Select(collection, multipleSelection?), SelectAll(), UnSelect(obj), ClearSelection()
- Drag, resize, and rotate elements (user interaction + programmatic)
- Programmatic transforms:
Drag(obj, tx, ty), Rotate(obj, angle, pivot?), Scale(obj, sx, sy, pivot)
- Zoom and pan: mouse wheel, toolbar,
Zoom(factor, focusPoint), ResetZoom(), Pan(hOffset, vOffset, focusPoint?)
BringIntoView(DiagramRect) — scroll viewport to show a region
BringIntoCenter(DiagramRect) — scroll viewport to center a region
FitToPage(FitOptions?) — fit content to viewport (sync; FitMode.Width/Height/Both, DiagramRegion.Content/PageSettings)
Nudge(Direction, int?) — move selected elements by pixels; default 1px; Direction.Top/Bottom/Left/Right
- Z-Order:
BringToFront(), BringForward(), SendBackward(), SendToBack() — must Select() first
- Clipboard:
Copy(), Cut(), Paste(collection?), Delete(collection?)
- Group/Ungroup:
Group(), Ungroup(), AddChildAsync(group, child), RemoveChild(group, child)
- Inline text editing:
StartTextEdit(obj, annotationId?)
- Keyboard shortcuts (built-in table) and
CommandManager (custom/override shortcuts via child component)
CommandManager uses KeyboardCommand + KeyGesture (DiagramKeys + ModifierKeys) + CommandKeyArgs
- Snapping to grid or objects
- Alignment, spacing, and sizing commands (
SetAlign, SetDistribute, SetSameSize — all sync)
- User handles (custom action buttons on selection)
- Undo/redo:
Undo(), Redo() (sync); StartGroupAction() / EndGroupAction() for batched undo steps
- History:
AddHistoryEntry(entry), ClearHistory()
- Utility:
GetObject(id), GetPageBounds(x?, y?), Clear() (removes all elements)
- Batch updates:
BeginUpdate() + await EndUpdateAsync() — group multiple changes into one render pass
- Add multiple elements:
await AddDiagramElementsAsync(DiagramObjectCollection<NodeBase>)
Events
📄 Read: references/events.md
- Diagram-level events (Created, Click, Drop)
- Node events (NodeCreating, PositionChanged, SizeChanged)
- Connector events (ConnectionChanged, SegmentChanged)
- Selection events (SelectionChanged)
- History change events (HistoryChanged for undo/redo)
- Event argument types and usage patterns
Serialization
📄 Read: references/serialization.md
- Saving diagram state as JSON string
- Loading a diagram from saved JSON
- Custom serialization properties
- Partial diagram save and restore patterns
Export & Print
📄 Read: references/export-print.md
- Exporting to PNG, JPEG, SVG formats
- Export region options (diagram, page, content)
- Scale and margin settings
- Print configuration
- Custom page size and orientation
- Fit diagram to single page on print
Styling
📄 Read: references/styling.md
- CSS class customization (
CssClass property)
- Built-in themes (Material, Bootstrap, Fluent, Tailwind)
- Node and connector style properties
- Selection and hover styles
- Theme Studio customization
- CSS variable overrides
UML Sequence Diagrams
📄 Read: references/uml-sequence.md
- UML sequence diagram setup
- Lifelines and activation boxes
- Message types (synchronous, asynchronous, return, create, destroy)
- UML interaction shapes and connectors
await UpdateFromModelAsync() — refresh diagram after programmatic model changes
UML Class Diagram
📄 Read: references/uml-class-diagram.md
- Creating Class, Interface, and Enumeration nodes with attributes, methods, and members
- Visibility scopes, method parameters, separator rows
- Styling header, section headers (
UmlSectionHeaderSettings), and row-level TextStyle
- Six relationship types: Association, Aggregation, Composition, Inheritance, Dependency, Realization
- Directional / bi-directional association flow; multiplicity labels
- Adding and removing members at runtime (
Add, RemoveAt, Remove)
CollectionChanging / CollectionChanged events; inline text editing (F2, StartTextEdit)
- Symbol Palette integration for drag-and-drop UML shapes
Collaborative Editing
📄 Read: references/collaborative-editing.md
- Setting up real-time collaborative diagram editing
- SignalR hub configuration
- Blazor Server and WASM app integration
- Handling real-time sync and conflict resolution
- Delta sync:
GetDiagramUpdates(HistoryChangedEventArgs) + await SetDiagramUpdatesAsync(updates) — efficient change propagation
Overview Component
📄 Read: references/overview-component.md
- Adding
SfDiagramOverviewComponent as a miniature thumbnail panel
- Linking the overview to the main diagram via
SourceID / ID
- Controlling panel size with
Width and Height
- Zoom and pan interactions (drag, resize, click, draw-region)
- Enabling or disabling interactions with
DiagramOverviewConstraints
- Required
@using Syncfusion.Blazor.Diagram.Overview namespace.
@using Syncfusion.Blazor.Diagram
@using Syncfusion.Blazor.Diagram.Overview
@using System.Collections.ObjectModel
<SfDiagramComponent ID="element"
Width="100%"
Height="500px">
</SfDiagramComponent>
<!-- Overview panel linked to the diagram above -->
<SfDiagramOverviewComponent Height="150px" SourceID="element" />
Advanced Features
📄 Read: references/advanced-features.md
- Context menu (built-in and custom items)
- Tooltips for nodes, connectors, ports, user handles
- Programmatic tooltips:
await ShowTooltipAsync(obj) / await HideTooltipAsync(obj) — requires OpensOn = "Custom"
- Gridlines and rulers
- Scroll settings and page settings
- Container and group nodes
- Flip (horizontal/vertical)
- Constraints (restricting behavior per element)
- Localization (static text translation)
- Accessibility (WCAG 2.1, keyboard navigation)
- Migration from classic to native diagram
Common Mistakes
Annotation Editing
⚠️ AllowEditing does NOT exist on ShapeAnnotation or PathAnnotation.
Inline editing is on by default — no property is needed to enable it.
To disable editing, set Constraints = AnnotationConstraints.ReadOnly:
// ❌ Wrong — CS0117: AllowEditing does not exist
new ShapeAnnotation { Content = "Label", AllowEditing = false }
// ✅ Correct — use AnnotationConstraints.ReadOnly to disable editing
new ShapeAnnotation { Content = "Label", Constraints = AnnotationConstraints.ReadOnly }
EndUpdateAsync Method
⚠️ Always use EndUpdateAsync() (async) — EndUpdate() (sync, non-async) does NOT exist and will cause a compile error.
Use BeginUpdate()/EndUpdateAsync() when changing multiple properties at once — await is required:
// ❌ Wrong — EndUpdate() does not exist
diagram.BeginUpdate();
// ... changes ...
diagram.EndUpdate();
// ✅ Correct — EndUpdateAsync is async
diagram.BeginUpdate();
// ... changes ...
await diagram.EndUpdateAsync();
Click Event
⚠️ ClickEventArgs name collision: If your page also uses @using Syncfusion.Blazor.Navigations (or Buttons),
ClickEventArgs becomes ambiguous. Always qualify it:
// ✅ Use the fully qualified type in the handler signature
private void OnClick(Syncfusion.Blazor.Diagram.ClickEventArgs args) { }
⚠️ args.Count is NOT an int field — it is a method that returns an int.
Do NOT compare it directly with == inline without storing the result first:
// ❌ Wrong — CS0019: Operator '==' cannot be applied to operands of type 'method group' and 'int'
if (args.Count == 2)
// ✅ Correct — store result then compare
int clickCount = args.Count;
if (clickCount == 2) { /* double-click */ }
SizeChanged Event
⚠️ SizeChangedEventArgs.Element is typed as DiagramSelectionSettings, not Node.
Pattern-matching args.Element is Node n always fails with CS8121.
Cast to DiagramSelectionSettings and read .Nodes[0] to get the resized node:
// ❌ Wrong — CS8121: DiagramSelectionSettings cannot match Node
if (args.Element is Node n) { }
// ✅ Correct — Element is DiagramSelectionSettings
if (args.Element is DiagramSelectionSettings sel && sel.Nodes.Count > 0)
{
var node = sel.Nodes[0];
double w = args.NewValue.Width;
double h = args.NewValue.Height;
}
⚠️ args.NewValue.Width and args.NewValue.Height are plain double, not double?.
Using ?? on them causes CS0019. Assign them directly:
// ❌ Wrong — CS0019
double w = args.NewValue.Width ?? 0;
// ✅ Correct
double w = args.NewValue.Width;
Selection Changed Event
⚠️ SelectionChangedEventArgs name collision: If your page also uses @using Syncfusion.Blazor.Buttons
(or other Syncfusion packages), SelectionChangedEventArgs becomes ambiguous. Always qualify it:
// ✅ Fully qualified
private void OnSelectionChanged(Syncfusion.Blazor.Diagram.SelectionChangedEventArgs args) { }
⚠️ args.NewValue is a DiagramSelectionSettings object — NOT a Node, NOT a collection:
- Pattern-matching
args.NewValue is Node always fails with CS8121
- Iterating
args.NewValue as a collection fails — it is a single settings object
- The only correct approach is to read
_diagram.SelectionSettings.Nodes / .Connectors:
// ❌ Wrong — CS8121: DiagramSelectionSettings cannot match Node
if (args.NewValue is Node n) { }
// ❌ Wrong — DiagramSelectionSettings is not IEnumerable
foreach (var item in args.NewValue) { }
// ✅ Correct — use SelectionSettings on the diagram reference
foreach (var node in _diagram.SelectionSettings.Nodes)
Console.WriteLine(node.ID);
foreach (var conn in _diagram.SelectionSettings.Connectors)
Console.WriteLine(conn.ID);
Text Changed Event
⚠️ TextChangedEventArgs does NOT exist — using it causes CS0246.
The correct event args type is TextChangeEventArgs (no d):
// ❌ Wrong — CS0246: TextChangedEventArgs not found
private void OnTextChanged(TextChangedEventArgs args) { }
// ✅ Correct
private void OnTextChanged(TextChangeEventArgs args) { }
Drag Start Event
⚠️ DragStartEventArgs is ambiguous when Syncfusion.Blazor.Popups (or other packages that expose DragStartEventArgs) is also referenced.
Always qualify it as Syncfusion.Blazor.Diagram.DragStartEventArgs:
// ❌ Wrong — CS0104: ambiguous reference between Diagram and Popups
private void OnDragStart(DragStartEventArgs args) { }
// ✅ Correct — fully qualified
private void OnDragStart(Syncfusion.Blazor.Diagram.DragStartEventArgs args) { }
⚠️ DragEnterEventArgs does NOT exist in Syncfusion.Blazor.Diagram.
There is no DragEnter event on SfDiagramComponent that receives a DragEnterEventArgs.
The available drag events on SfDiagramComponent are: DragStart, Dragging, DragLeave, DragDrop — all for SymbolPalette drag-and-drop only.
For tracking when a node is being moved (internal drag), use PositionChanged:
// ❌ Wrong — DragEnterEventArgs does not exist
private void OnDragEnter(DragEnterEventArgs args) { }
// ❌ Wrong — OnPositionChange does not exist on SfDiagramComponent
<SfDiagramComponent />
// ✅ Correct — use PositionChanged
<SfDiagramComponent PositionChanged="OnPositionChanged" />
private void OnPositionChanged(PositionChangedEventArgs args)
{
if (args.Element is Node n)
Console.WriteLine($"Node {n.ID} moved to ({n.OffsetX}, {n.OffsetY})");
}
Snap Distance
⚠️ SnapObjectDistance does NOT exist on SnapSettings — using it causes InvalidOperationException: does not have a property matching the name 'SnapObjectDistance'.
The correct property name is SnapDistance:
@* ❌ Wrong — SnapObjectDistance does not exist *@
<SnapSettings SnapObjectDistance="5" />
@* ✅ Correct *@
<SnapSettings Constraints="SnapConstraints.SnapToObject" SnapDistance="5" />
Styling
⚠️ CssClass does NOT exist on SfDiagramComponent — using it causes
InvalidOperationException: Object of type 'SfDiagramComponent' does not have a property matching the name 'CssClass'.
Wrap the component in a <div> with a scoping class instead:
@* ❌ Wrong — CssClass does not exist on SfDiagramComponent *@
<SfDiagramComponent CssClass="my-diagram" />
@* ✅ Correct — use a wrapper div *@
<div class="my-diagram">
<SfDiagramComponent ... />
</div>
Phase Offset Property
⚠️ Phase.Offset does NOT exist — using it causes a compile error.
Use Phase.Width to set the size of a phase in a swimlane:
// ❌ Wrong — Offset does not exist on Phase
new Phase { ID = "ph1", Offset = 220 }
// ✅ Correct — use Width
new Phase { ID = "ph1", Width = 220 }
Lane Constraints Property
⚠️ Lane.Constraints does NOT exist and LaneConstraints enum does NOT exist.
Individual lanes cannot have constraints set via a Constraints property.
To restrict swimlane-level interactions, use SwimlaneConstraints on the Swimlane object itself:
// ❌ Wrong — Lane.Constraints and LaneConstraints do not exist
lane.Constraints = LaneConstraints.Default & ~LaneConstraints.ResizeEntries;
// ✅ Correct — set constraints on the Swimlane object
swimlane.Constraints = SwimlaneConstraints.Default & ~SwimlaneConstraints.Interaction;
FitMode.Page Value
⚠️ FitMode.Page does NOT exist — using it causes CS0117.
The correct values for FitMode are FitMode.Width and FitMode.Height:
// ❌ Wrong — FitMode.Page does not exist
new FitOptions { Mode = FitMode.Page }
// ✅ Correct — use FitMode.Width or FitMode.Height
new FitOptions { Mode = FitMode.Width, Region = DiagramRegion.Content }
LoadDiagram Method
⚠️ SfDiagramComponent.LoadDiagram() does NOT exist — using it causes a compile error.
Use the async version LoadDiagramAsync() instead:
// ❌ Wrong — LoadDiagram() does not exist
diagram.LoadDiagram(savedJson);
// ✅ Correct — use LoadDiagramAsync
await diagram.LoadDiagramAsync(savedJson);
FitToPageAsync Method
⚠️ SfDiagramComponent.FitToPageAsync() does NOT exist — using it causes a compile error.
Use the non-async overload FitToPage() instead:
// ❌ Wrong — FitToPageAsync does not exist
await diagram.FitToPageAsync(new FitOptions { Mode = FitMode.Width });
// ✅ Correct — use FitToPage (synchronous)
diagram.FitToPage(new FitOptions { Mode = FitMode.Width, Region = DiagramRegion.Content });
BasicShapes Enum
⚠️ BasicShapes does NOT exist — use NodeBasicShapes instead:
// ❌ Wrong
new BasicShape { Shape = BasicShapes.Rectangle }
// ✅ Correct
new BasicShape { Shape = NodeBasicShapes.Rectangle }
DiagramThickness Constructor
⚠️ DiagramThickness does NOT have a 4-argument constructor — using it causes CS1729: does not contain a constructor that takes 4 arguments.
Use the object initializer syntax with named properties instead:
// ❌ Wrong — CS1729: no 4-argument constructor
new DiagramThickness(20, 50, 20, 20)
// ✅ Correct — use object initializer with named properties
new DiagramThickness { Left = 20, Top = 50, Right = 20, Bottom = 20 }
// ✅ Correct — set only the sides you need
new DiagramThickness { Top = 50 }
PathAnnotation DragLimit Type
⚠️ PathAnnotation.DragLimit type is DiagramThickness — NOT Margin.
Using new Margin { ... } causes a type mismatch compile error (CS0029).
Always use new DiagramThickness { ... } for DragLimit:
// ❌ Wrong — CS0029: Margin cannot be assigned to DiagramThickness
new PathAnnotation
{
Constraints = AnnotationConstraints.Interaction,
DragLimit = new Margin { Left = 40, Right = 40, Top = 20, Bottom = 20 }
}
// ✅ Correct — DiagramThickness with object initializer
new PathAnnotation
{
Constraints = AnnotationConstraints.Interaction,
DragLimit = new DiagramThickness { Left = 40, Right = 40, Top = 20, Bottom = 20 }
}
ScrollSettings EnableAutoScroll Property
⚠️ CanAutoScroll does NOT exist on ScrollSettings — using it causes InvalidOperationException: does not have a property matching the name 'CanAutoScroll'.
The correct property name is EnableAutoScroll:
@* ❌ Wrong — CanAutoScroll does not exist *@
<ScrollSettings CanAutoScroll="true" />
@* ✅ Correct *@
<ScrollSettings EnableAutoScroll="true" />
Zoom, Undo, and Redo Methods
⚠️ ZoomAsync(), UndoAsync(), and RedoAsync() do NOT exist — using them causes a compile error.
Use the non-async overloads Zoom(), Undo(), and Redo() instead:
// ❌ Wrong — ZoomAsync, UndoAsync, RedoAsync do not exist
await _diagram.ZoomAsync(1.2, new DiagramPoint { X = 300, Y = 300 });
await _diagram.UndoAsync();
await _diagram.RedoAsync();
// ✅ Correct — use non-async overloads
_diagram.Zoom(1.2, new DiagramPoint { X = 300, Y = 300 });
_diagram.Undo();
_diagram.Redo();
Overview Component Namespace
⚠️ SfDiagramOverviewComponent requires an additional @using — it lives in Syncfusion.Blazor.Diagram.Overview, NOT in Syncfusion.Blazor.Diagram. Forgetting it causes CS0246:
@* ❌ Wrong — SfDiagramOverviewComponent not found without the Overview namespace *@
@using Syncfusion.Blazor.Diagram
@* ✅ Correct — both namespaces required *@
@using Syncfusion.Blazor.Diagram
@using Syncfusion.Blazor.Diagram.Overview
⚠️ SourceID must exactly match the ID set on SfDiagramComponent — the ID is NOT auto-generated; you must set it explicitly. A mismatch (including case) renders the overview empty:
@* ❌ Wrong — ID not set on the diagram; SourceID has nothing to link to *@
<SfDiagramComponent Width="100%" Height="500px" Nodes="@_nodes" />
<SfDiagramOverviewComponent SourceID="myDiagram" Height="150px" />
@* ✅ Correct — ID set on diagram, SourceID matches exactly *@
<SfDiagramComponent ID="myDiagram" Width="100%" Height="500px" Nodes="@_nodes" />
<SfDiagramOverviewComponent SourceID="myDiagram" Height="150px" />
⚠️ Do NOT nest SfDiagramOverviewComponent inside SfDiagramComponent — the overview is a sibling component rendered outside the diagram markup.
1---
2name: syncfusion-blazor-diagram
3description: Build and troubleshoot Syncfusion Blazor diagrams using SfDiagramComponent. Trigger for flowcharts, org charts, mind maps, BPMN, UML sequence, swimlanes, symbol palettes, nodes/connectors/ports/annotations, layouts, data binding, serialization (load/save), export/print, and collaborative editing questions. Provide Blazor + Syncfusion setup steps, configuration patterns, and sample snippets.
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7 category: "Data Visualization"
8---
9
10# Implementing Syncfusion Blazor Diagram
11
12A comprehensive skill for building interactive diagrams with the Syncfusion Blazor Diagram component — flowcharts, organizational charts, mind maps, BPMN process diagrams, UML sequence diagrams, network diagrams, and more.
13
14## When to Use This Skill
15
16Use this skill when you need to:
17- Create flowcharts, org charts, mind maps, or network diagrams in Blazor
18- Work with `SfDiagramComponent`, nodes, connectors, or shapes
19- Configure automatic layouts (hierarchical, radial, mind map, org chart, flowchart)
20- Implement BPMN process diagrams with BPMN shapes
21- Build swimlane diagrams for process modeling
22- Add symbol palettes for drag-and-drop diagram building
23- Bind diagram data from a collection or remote source
24- Implement diagram interactions (selection, drag, resize, zoom, pan)
25- Export diagrams to PNG/JPEG/SVG or print them
26- Serialize and restore diagram state (save/load)
27- Enable collaborative real-time editing
28- Add UML sequence diagrams
29- Handle diagram events, annotations, and ports
30
31## Important: API Verification Required
32
33**API Verification Required**: Always verify API class names, properties, and signatures by reading reference files (`references/*.md`) BEFORE generating code examples. Do not assume or infer class names.
34⚠️ Before writing ANY code, review the **Common Mistakes** section directly below to avoid known invalid APIs and properties.
35
36
37## Quick Start
38
39```razor
40@using Syncfusion.Blazor.Diagram
41
42<SfDiagramComponent Width="100%" Height="600px" Nodes="@nodes" Connectors="@connectors" />
43
44@code {
45 DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>
46 {
47 new Node
48 {
49 ID = "node1", OffsetX = 150, OffsetY = 150,
50 Width = 100, Height = 50,
51 Style = new ShapeStyle { Fill = "#6BA5D7", StrokeColor = "white" },
52 Annotations = new DiagramObjectCollection<ShapeAnnotation>
53 {
54 new ShapeAnnotation { Content = "Start" }
55 }
56 }
57 };
58 DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>
59 {
60 new Connector { ID = "conn1", SourceID = "node1", TargetID = "node2" }
61 };
62}
63```
64
65## Common Patterns
66
67| Goal | Reference |
68|------|-----------|
69| First diagram setup | [references/getting-started.md](references/getting-started.md) |
70| Add/configure nodes | [references/nodes.md](references/nodes.md) |
71| Add/configure connectors | [references/connectors.md](references/connectors.md) |
72| Use built-in shapes | [references/shapes.md](references/shapes.md) |
73| Add text labels | [references/annotations.md](references/annotations.md) |
74| Define connection points | [references/ports.md](references/ports.md) |
75| Org charts / auto-layout | [references/layout.md](references/layout.md) |
76| Swimlane diagrams | [references/swimlane.md](references/swimlane.md) |
77| BPMN process diagrams | [references/bpmn.md](references/bpmn.md) |
78| Drag-and-drop palette | [references/symbol-palette.md](references/symbol-palette.md) |
79| Bind data to diagram | [references/data-binding.md](references/data-binding.md) |
80| Selection, drag, zoom | [references/interaction.md](references/interaction.md) |
81| Handle diagram events | [references/events.md](references/events.md) |
82| Save and load diagrams | [references/serialization.md](references/serialization.md) |
83| Export / print | [references/export-print.md](references/export-print.md) |
84| CSS / theme styling | [references/styling.md](references/styling.md) |
85| UML sequence diagrams | [references/uml-sequence.md](references/uml-sequence.md) |
86| Real-time collaboration | [references/collaborative-editing.md](references/collaborative-editing.md) |
87| Context menu, tooltips, rulers, localization | [references/advanced-features.md](references/advanced-features.md) |
88| Miniature overview / bird's-eye navigation | [references/overview-component.md](references/overview-component.md) |
89
90---
91
92## Documentation and Navigation Guide
93
94### Getting Started
95📄 **Read:** [references/getting-started.md](references/getting-started.md)
96- NuGet package installation (`Syncfusion.Blazor.Diagram`)
97- Service registration and namespace imports
98- Setup for Blazor Server, WebAssembly, MAUI
99- CSS/theme configuration
100- Minimal working diagram example
101
102### Nodes
103📄 **Read:** [references/nodes.md](references/nodes.md)
104- Creating and configuring nodes
105- Node types: basic, flow shape, path, image, HTML, native
106- Node positioning, sizing, z-order
107- Node style (fill, stroke, opacity)
108- Expand/collapse children
109- Node events and interaction
110
111### Connectors
112📄 **Read:** [references/connectors.md](references/connectors.md)
113- Creating connectors between nodes or free-floating
114- Segment types: straight, orthogonal, bezier
115- Multiple segments per connector
116- Arrows, line style, and decoration
117- Connector interaction (bend, drag endpoints)
118- Connector events
119
120### Shapes
121📄 **Read:** [references/shapes.md](references/shapes.md)
122- Built-in basic shapes (rectangle, ellipse, triangle, etc.)
123- Flow shapes (process, decision, terminator, etc.)
124- Path shapes (custom SVG paths)
125- Image and HTML content shapes
126- Native SVG shapes
127- Choosing the right shape type
128
129### Annotations
130📄 **Read:** [references/annotations.md](references/annotations.md)
131- Adding text labels to nodes and connectors
132- Annotation positioning and alignment
133- Font, color, and style customization
134- Inline editing of annotations
135- Multiple annotations per element
136- Annotation interaction events
137- Interaction constraints: `AnnotationConstraints` flags, `DragLimit` (PathAnnotation)
138- Hyperlinks with `Hyperlink` (`Url`, `Content`, `OpenMode`)
139- Events: SelectionChanging/Changed, PositionChanging/Changed, SizeChanging/Changed, RotationChanging/Changed, TextChanging/Changed
140
141### Ports
142📄 **Read:** [references/ports.md](references/ports.md)
143- Connection ports (fixed connection points on nodes)
144- Dynamic ports (created at runtime)
145- Port positioning (relative and absolute)
146- Port appearance and visibility
147- Restricting connections to specific ports
148
149### Layout
150📄 **Read:** [references/layout.md](references/layout.md)
151- Automatic layout overview and when to use each type
152- Hierarchical tree layout (top-down, left-right)
153- Organizational chart layout
154- Mind map layout
155- Radial tree layout
156- Flowchart layout
157- Force-directed tree layout
158- Complex hierarchical layout
159- Layout spacing, margin, and orientation settings
160- Layout events and callbacks
161- `await DoLayoutAsync()` — refresh layout at runtime after adding/removing nodes
162
163### Swimlane
164📄 **Read:** [references/swimlane.md](references/swimlane.md)
165- Creating swimlane diagrams
166- Adding lanes and configuring lane properties
167- Phase configuration (vertical/horizontal phases)
168- Swimlane symbol palette integration
169- Swimlane interactions
170
171```razor
172<SfDiagramComponent Height="600px" Swimlanes="@swimlanes" />
173
174@code {
175 DiagramObjectCollection<Swimlane> swimlanes = new();
176
177 protected override void OnInitialized()
178 {
179 swimlanes.Add(new Swimlane
180 {
181 ID = "swimlane1",
182 OffsetX = 400, OffsetY = 300,
183 Width = 600, Height = 200,
184 Lanes = new DiagramObjectCollection<Lane>()
185 {
186 new Lane(){
187 Height = 100,
188 Header = new SwimlaneHeader(){
189 Width = 30,
190 Annotation = new ShapeAnnotation(){ Content = "Consumer" }
191 },
192 Children = new DiagramObjectCollection<Node>()
193 {
194 new Node(){Height = 50, Width = 50, LaneOffsetX = 250, LaneOffsetY = 30},
195 }
196 },
197 }
198 });
199 }
200}
201```
202
203### BPMN
204📄 **Read:** [references/bpmn.md](references/bpmn.md)
205- BPMN shape types (events, activities, gateways, data)
206- BPMN event types (start, end, intermediate, boundary)
207- BPMN activity types (task, subprocess, call activity)
208- BPMN gateway types (exclusive, parallel, inclusive, etc.)
209- BPMN connectors (sequence flow, message flow, association)
210- Data objects and data stores
211- Expanded sub-process
212- BPMN text annotation
213
214```razor
215// Exclusive gateway (XOR)
216nodes.Add(new Node
217{
218 ID = "gateway1", OffsetX = 300, OffsetY = 200, Width = 50, Height = 50,
219 Shape = new BpmnGateway
220 {
221 GatewayType = BpmnGatewayType.Exclusive
222 }
223});
224```
225
226### Symbol Palette
227📄 **Read:** [references/symbol-palette.md](references/symbol-palette.md)
228- Setting up `SfSymbolPaletteComponent`
229- Defining palette groups and symbols
230- Custom symbols and stencils
231- Drag-and-drop from palette to diagram
232- Palette search and customization
233
234### Data Binding
235📄 **Read:** [references/data-binding.md](references/data-binding.md)
236- Binding diagram from a flat list or IEnumerable
237- Hierarchical data binding (parent-child relationships)
238- Remote data source integration
239- Runtime CRUD: `await ReadDataAsync(query?)`, `await InsertDataAsync(data)`, `await UpdateDataAsync(keyField, data)`, `await DeleteDataAsync(keyField, value)`
240- `await RefreshDataSourceAsync()` — reload all data and rebuild layout
241- Mapping data fields to node/connector properties
242
243### Interaction & Commands
244📄 **Read:** [references/interaction.md](references/interaction.md)
245- Selection: `Select(collection, multipleSelection?)`, `SelectAll()`, `UnSelect(obj)`, `ClearSelection()`
246- Drag, resize, and rotate elements (user interaction + programmatic)
247- Programmatic transforms: `Drag(obj, tx, ty)`, `Rotate(obj, angle, pivot?)`, `Scale(obj, sx, sy, pivot)`
248- Zoom and pan: mouse wheel, toolbar, `Zoom(factor, focusPoint)`, `ResetZoom()`, `Pan(hOffset, vOffset, focusPoint?)`
249- `BringIntoView(DiagramRect)` — scroll viewport to show a region
250- `BringIntoCenter(DiagramRect)` — scroll viewport to center a region
251- `FitToPage(FitOptions?)` — fit content to viewport (sync; `FitMode.Width/Height/Both`, `DiagramRegion.Content/PageSettings`)
252- `Nudge(Direction, int?)` — move selected elements by pixels; default 1px; `Direction.Top/Bottom/Left/Right`
253- Z-Order: `BringToFront()`, `BringForward()`, `SendBackward()`, `SendToBack()` — must `Select()` first
254- Clipboard: `Copy()`, `Cut()`, `Paste(collection?)`, `Delete(collection?)`
255- Group/Ungroup: `Group()`, `Ungroup()`, `AddChildAsync(group, child)`, `RemoveChild(group, child)`
256- Inline text editing: `StartTextEdit(obj, annotationId?)`
257- Keyboard shortcuts (built-in table) and `CommandManager` (custom/override shortcuts via child component)
258- `CommandManager` uses `KeyboardCommand` + `KeyGesture` (`DiagramKeys` + `ModifierKeys`) + `CommandKeyArgs`
259- Snapping to grid or objects
260- Alignment, spacing, and sizing commands (`SetAlign`, `SetDistribute`, `SetSameSize` — all sync)
261- User handles (custom action buttons on selection)
262- Undo/redo: `Undo()`, `Redo()` (sync); `StartGroupAction()` / `EndGroupAction()` for batched undo steps
263- History: `AddHistoryEntry(entry)`, `ClearHistory()`
264- Utility: `GetObject(id)`, `GetPageBounds(x?, y?)`, `Clear()` (removes all elements)
265- Batch updates: `BeginUpdate()` + `await EndUpdateAsync()` — group multiple changes into one render pass
266- Add multiple elements: `await AddDiagramElementsAsync(DiagramObjectCollection<NodeBase>)`
267
268### Events
269📄 **Read:** [references/events.md](references/events.md)
270- Diagram-level events (Created, Click, Drop)
271- Node events (NodeCreating, PositionChanged, SizeChanged)
272- Connector events (ConnectionChanged, SegmentChanged)
273- Selection events (SelectionChanged)
274- History change events (HistoryChanged for undo/redo)
275- Event argument types and usage patterns
276
277### Serialization
278📄 **Read:** [references/serialization.md](references/serialization.md)
279- Saving diagram state as JSON string
280- Loading a diagram from saved JSON
281- Custom serialization properties
282- Partial diagram save and restore patterns
283
284### Export & Print
285📄 **Read:** [references/export-print.md](references/export-print.md)
286- Exporting to PNG, JPEG, SVG formats
287- Export region options (diagram, page, content)
288- Scale and margin settings
289- Print configuration
290- Custom page size and orientation
291- Fit diagram to single page on print
292
293### Styling
294📄 **Read:** [references/styling.md](references/styling.md)
295- CSS class customization (`CssClass` property)
296- Built-in themes (Material, Bootstrap, Fluent, Tailwind)
297- Node and connector style properties
298- Selection and hover styles
299- Theme Studio customization
300- CSS variable overrides
301
302### UML Sequence Diagrams
303📄 **Read:** [references/uml-sequence.md](references/uml-sequence.md)
304- UML sequence diagram setup
305- Lifelines and activation boxes
306- Message types (synchronous, asynchronous, return, create, destroy)
307- UML interaction shapes and connectors
308- `await UpdateFromModelAsync()` — refresh diagram after programmatic model changes
309
310### UML Class Diagram
311📄 **Read:** [references/uml-class-diagram.md](references/uml-class-diagram.md)
312- Creating Class, Interface, and Enumeration nodes with attributes, methods, and members
313- Visibility scopes, method parameters, separator rows
314- Styling header, section headers (`UmlSectionHeaderSettings`), and row-level `TextStyle`
315- Six relationship types: Association, Aggregation, Composition, Inheritance, Dependency, Realization
316- Directional / bi-directional association flow; multiplicity labels
317- Adding and removing members at runtime (`Add`, `RemoveAt`, `Remove`)
318- `CollectionChanging` / `CollectionChanged` events; inline text editing (`F2`, `StartTextEdit`)
319- Symbol Palette integration for drag-and-drop UML shapes
320
321### Collaborative Editing
322📄 **Read:** [references/collaborative-editing.md](references/collaborative-editing.md)
323- Setting up real-time collaborative diagram editing
324- SignalR hub configuration
325- Blazor Server and WASM app integration
326- Handling real-time sync and conflict resolution
327- Delta sync: `GetDiagramUpdates(HistoryChangedEventArgs)` + `await SetDiagramUpdatesAsync(updates)` — efficient change propagation
328
329### Overview Component
330📄 **Read:** [references/overview-component.md](references/overview-component.md)
331- Adding `SfDiagramOverviewComponent` as a miniature thumbnail panel
332- Linking the overview to the main diagram via `SourceID` / `ID`
333- Controlling panel size with `Width` and `Height`
334- Zoom and pan interactions (drag, resize, click, draw-region)
335- Enabling or disabling interactions with `DiagramOverviewConstraints`
336- Required `@using Syncfusion.Blazor.Diagram.Overview` namespace.
337
338```razor
339@using Syncfusion.Blazor.Diagram
340@using Syncfusion.Blazor.Diagram.Overview
341@using System.Collections.ObjectModel
342
343<SfDiagramComponent ID="element"
344 Width="100%"
345 Height="500px">
346</SfDiagramComponent>
347
348<!-- Overview panel linked to the diagram above -->
349<SfDiagramOverviewComponent Height="150px" SourceID="element" />
350```
351
352### Advanced Features
353📄 **Read:** [references/advanced-features.md](references/advanced-features.md)
354- Context menu (built-in and custom items)
355- Tooltips for nodes, connectors, ports, user handles
356- Programmatic tooltips: `await ShowTooltipAsync(obj)` / `await HideTooltipAsync(obj)` — requires `OpensOn = "Custom"`
357- Gridlines and rulers
358- Scroll settings and page settings
359- Container and group nodes
360- Flip (horizontal/vertical)
361- Constraints (restricting behavior per element)
362- Localization (static text translation)
363- Accessibility (WCAG 2.1, keyboard navigation)
364- Migration from classic to native diagram
365
366
367### Common Mistakes
368
369#### Annotation Editing
370
371> **⚠️ `AllowEditing` does NOT exist** on `ShapeAnnotation` or `PathAnnotation`.
372> Inline editing is **on by default** — no property is needed to enable it.
373> To **disable** editing, set `Constraints = AnnotationConstraints.ReadOnly`:
374> ```csharp
375> // ❌ Wrong — CS0117: AllowEditing does not exist
376> new ShapeAnnotation { Content = "Label", AllowEditing = false }
377>
378> // ✅ Correct — use AnnotationConstraints.ReadOnly to disable editing
379> new ShapeAnnotation { Content = "Label", Constraints = AnnotationConstraints.ReadOnly }
380> ```
381
382#### EndUpdateAsync Method
383
384> **⚠️ Always use `EndUpdateAsync()`** (async) — `EndUpdate()` (sync, non-async) does NOT exist and will cause a compile error.
385> Use `BeginUpdate()`/`EndUpdateAsync()` when changing multiple properties at once — `await` is required:
386> ```csharp
387> // ❌ Wrong — EndUpdate() does not exist
388> diagram.BeginUpdate();
389> // ... changes ...
390> diagram.EndUpdate();
391>
392> // ✅ Correct — EndUpdateAsync is async
393> diagram.BeginUpdate();
394> // ... changes ...
395> await diagram.EndUpdateAsync();
396> ```
397
398#### Click Event
399
400> **⚠️ `ClickEventArgs` name collision:** If your page also uses `@using Syncfusion.Blazor.Navigations` (or Buttons),
401> `ClickEventArgs` becomes ambiguous. Always qualify it:
402> ```csharp
403> // ✅ Use the fully qualified type in the handler signature
404> private void OnClick(Syncfusion.Blazor.Diagram.ClickEventArgs args) { }
405> ```
406
407> **⚠️ `args.Count` is NOT an `int` field** — it is a **method** that returns an `int`.
408> Do NOT compare it directly with `==` inline without storing the result first:
409> ```csharp
410> // ❌ Wrong — CS0019: Operator '==' cannot be applied to operands of type 'method group' and 'int'
411> if (args.Count == 2)
412>
413> // ✅ Correct — store result then compare
414> int clickCount = args.Count;
415> if (clickCount == 2) { /* double-click */ }
416> ```
417
418#### SizeChanged Event
419
420> **⚠️ `SizeChangedEventArgs.Element` is typed as `DiagramSelectionSettings`**, not `Node`.
421> Pattern-matching `args.Element is Node n` always fails with `CS8121`.
422> Cast to `DiagramSelectionSettings` and read `.Nodes[0]` to get the resized node:
423> ```csharp
424> // ❌ Wrong — CS8121: DiagramSelectionSettings cannot match Node
425> if (args.Element is Node n) { }
426>
427> // ✅ Correct — Element is DiagramSelectionSettings
428> if (args.Element is DiagramSelectionSettings sel && sel.Nodes.Count > 0)
429> {
430> var node = sel.Nodes[0];
431> double w = args.NewValue.Width;
432> double h = args.NewValue.Height;
433> }
434> ```
435
436> **⚠️ `args.NewValue.Width` and `args.NewValue.Height` are plain `double`**, not `double?`.
437> Using `??` on them causes `CS0019`. Assign them directly:
438> ```csharp
439> // ❌ Wrong — CS0019
440> double w = args.NewValue.Width ?? 0;
441>
442> // ✅ Correct
443> double w = args.NewValue.Width;
444> ```
445
446#### Selection Changed Event
447
448> **⚠️ `SelectionChangedEventArgs` name collision:** If your page also uses `@using Syncfusion.Blazor.Buttons`
449> (or other Syncfusion packages), `SelectionChangedEventArgs` becomes ambiguous. Always qualify it:
450> ```csharp
451> // ✅ Fully qualified
452> private void OnSelectionChanged(Syncfusion.Blazor.Diagram.SelectionChangedEventArgs args) { }
453> ```
454
455> **⚠️ `args.NewValue` is a `DiagramSelectionSettings` object — NOT a `Node`, NOT a collection:**
456> - Pattern-matching `args.NewValue is Node` always fails with `CS8121`
457> - Iterating `args.NewValue` as a collection fails — it is a single settings object
458> - The **only correct approach** is to read `_diagram.SelectionSettings.Nodes` / `.Connectors`:
459> ```csharp
460> // ❌ Wrong — CS8121: DiagramSelectionSettings cannot match Node
461> if (args.NewValue is Node n) { }
462>
463> // ❌ Wrong — DiagramSelectionSettings is not IEnumerable
464> foreach (var item in args.NewValue) { }
465>
466> // ✅ Correct — use SelectionSettings on the diagram reference
467> foreach (var node in _diagram.SelectionSettings.Nodes)
468> Console.WriteLine(node.ID);
469> foreach (var conn in _diagram.SelectionSettings.Connectors)
470> Console.WriteLine(conn.ID);
471> ```
472
473#### Text Changed Event
474
475> **⚠️ `TextChangedEventArgs` does NOT exist** — using it causes `CS0246`.
476> The correct event args type is **`TextChangeEventArgs`** (no `d`):
477> ```csharp
478> // ❌ Wrong — CS0246: TextChangedEventArgs not found
479> private void OnTextChanged(TextChangedEventArgs args) { }
480>
481> // ✅ Correct
482> private void OnTextChanged(TextChangeEventArgs args) { }
483> ```
484
485#### Drag Start Event
486
487> **⚠️ `DragStartEventArgs` is ambiguous** when `Syncfusion.Blazor.Popups` (or other packages that expose `DragStartEventArgs`) is also referenced.
488> Always qualify it as `Syncfusion.Blazor.Diagram.DragStartEventArgs`:
489> ```csharp
490> // ❌ Wrong — CS0104: ambiguous reference between Diagram and Popups
491> private void OnDragStart(DragStartEventArgs args) { }
492>
493> // ✅ Correct — fully qualified
494> private void OnDragStart(Syncfusion.Blazor.Diagram.DragStartEventArgs args) { }
495> ```
496
497> **⚠️ `DragEnterEventArgs` does NOT exist** in `Syncfusion.Blazor.Diagram`.
498> There is **no `DragEnter` event** on `SfDiagramComponent` that receives a `DragEnterEventArgs`.
499> The available drag events on `SfDiagramComponent` are: `DragStart`, `Dragging`, `DragLeave`, `DragDrop` — all for **SymbolPalette** drag-and-drop only.
500> For tracking when a node is **being moved** (internal drag), use `PositionChanged`:
501> ```csharp
502> // ❌ Wrong — DragEnterEventArgs does not exist
503> private void OnDragEnter(DragEnterEventArgs args) { }
504>
505> // ❌ Wrong — OnPositionChange does not exist on SfDiagramComponent
506> <SfDiagramComponent OnPositionChange="OnPositionChange" />
507>
508> // ✅ Correct — use PositionChanged
509> <SfDiagramComponent PositionChanged="OnPositionChanged" />
510>
511> private void OnPositionChanged(PositionChangedEventArgs args)
512> {
513> if (args.Element is Node n)
514> Console.WriteLine($"Node {n.ID} moved to ({n.OffsetX}, {n.OffsetY})");
515> }
516> ```
517
518#### Snap Distance
519
520> **⚠️ `SnapObjectDistance` does NOT exist** on `SnapSettings` — using it causes `InvalidOperationException: does not have a property matching the name 'SnapObjectDistance'`.
521> The correct property name is **`SnapDistance`**:
522> ```razor
523> @* ❌ Wrong — SnapObjectDistance does not exist *@
524> <SnapSettings SnapObjectDistance="5" />
525>
526> @* ✅ Correct *@
527> <SnapSettings Constraints="SnapConstraints.SnapToObject" SnapDistance="5" />
528> ```
529
530#### Styling
531
532> **⚠️ `CssClass` does NOT exist** on `SfDiagramComponent` — using it causes
533> `InvalidOperationException: Object of type 'SfDiagramComponent' does not have a property matching the name 'CssClass'`.
534> Wrap the component in a `<div>` with a scoping class instead:
535> ```razor
536> @* ❌ Wrong — CssClass does not exist on SfDiagramComponent *@
537> <SfDiagramComponent CssClass="my-diagram" />
538>
539> @* ✅ Correct — use a wrapper div *@
540> <div class="my-diagram">
541> <SfDiagramComponent ... />
542> </div>
543> ```
544
545#### Phase Offset Property
546
547> **⚠️ `Phase.Offset` does NOT exist** — using it causes a compile error.
548> Use **`Phase.Width`** to set the size of a phase in a swimlane:
549> ```csharp
550> // ❌ Wrong — Offset does not exist on Phase
551> new Phase { ID = "ph1", Offset = 220 }
552>
553> // ✅ Correct — use Width
554> new Phase { ID = "ph1", Width = 220 }
555> ```
556
557#### Lane Constraints Property
558
559> **⚠️ `Lane.Constraints` does NOT exist** and **`LaneConstraints` enum does NOT exist**.
560> Individual lanes cannot have constraints set via a `Constraints` property.
561> To restrict swimlane-level interactions, use **`SwimlaneConstraints`** on the **`Swimlane`** object itself:
562> ```csharp
563> // ❌ Wrong — Lane.Constraints and LaneConstraints do not exist
564> lane.Constraints = LaneConstraints.Default & ~LaneConstraints.ResizeEntries;
565>
566> // ✅ Correct — set constraints on the Swimlane object
567> swimlane.Constraints = SwimlaneConstraints.Default & ~SwimlaneConstraints.Interaction;
568> ```
569
570#### FitMode.Page Value
571
572> **⚠️ `FitMode.Page` does NOT exist** — using it causes `CS0117`.
573> The correct values for `FitMode` are **`FitMode.Width`** and **`FitMode.Height`**:
574> ```csharp
575> // ❌ Wrong — FitMode.Page does not exist
576> new FitOptions { Mode = FitMode.Page }
577>
578> // ✅ Correct — use FitMode.Width or FitMode.Height
579> new FitOptions { Mode = FitMode.Width, Region = DiagramRegion.Content }
580> ```
581
582#### LoadDiagram Method
583
584> **⚠️ `SfDiagramComponent.LoadDiagram()` does NOT exist** — using it causes a compile error.
585> Use the async version **`LoadDiagramAsync()`** instead:
586> ```csharp
587> // ❌ Wrong — LoadDiagram() does not exist
588> diagram.LoadDiagram(savedJson);
589>
590> // ✅ Correct — use LoadDiagramAsync
591> await diagram.LoadDiagramAsync(savedJson);
592> ```
593
594#### FitToPageAsync Method
595
596> **⚠️ `SfDiagramComponent.FitToPageAsync()` does NOT exist** — using it causes a compile error.
597> Use the non-async overload **`FitToPage()`** instead:
598> ```csharp
599> // ❌ Wrong — FitToPageAsync does not exist
600> await diagram.FitToPageAsync(new FitOptions { Mode = FitMode.Width });
601>
602> // ✅ Correct — use FitToPage (synchronous)
603> diagram.FitToPage(new FitOptions { Mode = FitMode.Width, Region = DiagramRegion.Content });
604> ```
605
606#### BasicShapes Enum
607
608> **⚠️ `BasicShapes` does NOT exist** — use `NodeBasicShapes` instead:
609> ```csharp
610> // ❌ Wrong
611> new BasicShape { Shape = BasicShapes.Rectangle }
612>
613> // ✅ Correct
614> new BasicShape { Shape = NodeBasicShapes.Rectangle }
615> ```
616
617#### DiagramThickness Constructor
618
619> **⚠️ `DiagramThickness` does NOT have a 4-argument constructor** — using it causes `CS1729: does not contain a constructor that takes 4 arguments`.
620> Use the **object initializer** syntax with named properties instead:
621> ```csharp
622> // ❌ Wrong — CS1729: no 4-argument constructor
623> new DiagramThickness(20, 50, 20, 20)
624>
625> // ✅ Correct — use object initializer with named properties
626> new DiagramThickness { Left = 20, Top = 50, Right = 20, Bottom = 20 }
627>
628> // ✅ Correct — set only the sides you need
629> new DiagramThickness { Top = 50 }
630> ```
631
632#### PathAnnotation DragLimit Type
633
634> **⚠️ `PathAnnotation.DragLimit` type is `DiagramThickness` — NOT `Margin`.**
635> Using `new Margin { ... }` causes a type mismatch compile error (`CS0029`).
636> Always use `new DiagramThickness { ... }` for `DragLimit`:
637> ```csharp
638> // ❌ Wrong — CS0029: Margin cannot be assigned to DiagramThickness
639> new PathAnnotation
640> {
641> Constraints = AnnotationConstraints.Interaction,
642> DragLimit = new Margin { Left = 40, Right = 40, Top = 20, Bottom = 20 }
643> }
644>
645> // ✅ Correct — DiagramThickness with object initializer
646> new PathAnnotation
647> {
648> Constraints = AnnotationConstraints.Interaction,
649> DragLimit = new DiagramThickness { Left = 40, Right = 40, Top = 20, Bottom = 20 }
650> }
651> ```
652
653#### ScrollSettings EnableAutoScroll Property
654
655> **⚠️ `CanAutoScroll` does NOT exist** on `ScrollSettings` — using it causes `InvalidOperationException: does not have a property matching the name 'CanAutoScroll'`.
656> The correct property name is **`EnableAutoScroll`**:
657> ```razor
658> @* ❌ Wrong — CanAutoScroll does not exist *@
659> <ScrollSettings CanAutoScroll="true" />
660>
661> @* ✅ Correct *@
662> <ScrollSettings EnableAutoScroll="true" />
663> ```
664
665#### Zoom, Undo, and Redo Methods
666
667> **⚠️ `ZoomAsync()`, `UndoAsync()`, and `RedoAsync()` do NOT exist** — using them causes a compile error.
668> Use the non-async overloads **`Zoom()`**, **`Undo()`**, and **`Redo()`** instead:
669> ```csharp
670> // ❌ Wrong — ZoomAsync, UndoAsync, RedoAsync do not exist
671> await _diagram.ZoomAsync(1.2, new DiagramPoint { X = 300, Y = 300 });
672> await _diagram.UndoAsync();
673> await _diagram.RedoAsync();
674>
675> // ✅ Correct — use non-async overloads
676> _diagram.Zoom(1.2, new DiagramPoint { X = 300, Y = 300 });
677> _diagram.Undo();
678> _diagram.Redo();
679> ```
680
681#### Overview Component Namespace
682
683> **⚠️ `SfDiagramOverviewComponent` requires an additional `@using`** — it lives in `Syncfusion.Blazor.Diagram.Overview`, NOT in `Syncfusion.Blazor.Diagram`. Forgetting it causes `CS0246`:
684> ```razor
685> @* ❌ Wrong — SfDiagramOverviewComponent not found without the Overview namespace *@
686> @using Syncfusion.Blazor.Diagram
687>
688> @* ✅ Correct — both namespaces required *@
689> @using Syncfusion.Blazor.Diagram
690> @using Syncfusion.Blazor.Diagram.Overview
691> ```
692
693> **⚠️ `SourceID` must exactly match the `ID` set on `SfDiagramComponent`** — the `ID` is NOT auto-generated; you must set it explicitly. A mismatch (including case) renders the overview empty:
694> ```razor
695> @* ❌ Wrong — ID not set on the diagram; SourceID has nothing to link to *@
696> <SfDiagramComponent Width="100%" Height="500px" Nodes="@_nodes" />
697> <SfDiagramOverviewComponent SourceID="myDiagram" Height="150px" />
698>
699> @* ✅ Correct — ID set on diagram, SourceID matches exactly *@
700> <SfDiagramComponent ID="myDiagram" Width="100%" Height="500px" Nodes="@_nodes" />
701> <SfDiagramOverviewComponent SourceID="myDiagram" Height="150px" />
702> ```
703
704> **⚠️ Do NOT nest `SfDiagramOverviewComponent` inside `SfDiagramComponent`** — the overview is a sibling component rendered outside the diagram markup.