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