syncfusion/wpf-ui-components-skills / skills/syncfusion-wpf-diagram
syncfusion-wpf-diagram
VerifiedComplete guide for implementing Syncfusion WPF Diagram (SfDiagram) in Windows Presentation Foundation applications. Use this when working with diagrams like flowcharts, org charts, BPMN, or UML in WPF. Covers creating diagrams, adding nodes and connectors, configuring automatic layouts, implementing BPMN and UML shapes, setting up symbol palettes, data binding, export functionality, and appearance customization.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.2 KB |
| references/annotations.md | markdown | 6.0 KB |
| references/automatic-layouts.md | markdown | 8.1 KB |
| references/bpmn-shapes.md | markdown | 8.2 KB |
| references/commands.md | markdown | 7.2 KB |
| references/connectors.md | markdown | 7.5 KB |
| references/data-source.md | markdown | 7.2 KB |
| references/diagram-customization.md | markdown | 8.4 KB |
| references/export-print.md | markdown | 7.1 KB |
| references/getting-started.md | markdown | 6.7 KB |
| references/interaction.md | markdown | 7.8 KB |
| references/nodes.md | markdown | 7.7 KB |
| references/performance-constraints.md | markdown | 10.7 KB |
| references/ports.md | markdown | 9.5 KB |
| references/serialization-undo-redo.md | markdown | 6.0 KB |
| references/stencil.md | markdown | 8.3 KB |
| references/swimlane.md | markdown | 11.3 KB |
| references/uml-diagrams.md | markdown | 8.2 KB |
references/getting-started.md
View on GitHub# Getting Started with WPF Diagram (SfDiagram)
## Overview
SfDiagram is found in the `Syncfusion.UI.Xaml.Diagram` namespace and added via the `Syncfusion.SfDiagram.WPF` NuGet package. This guide covers project setup through a working flowchart.
## Assembly Deployment
### NuGet Installation (Recommended)
```powershell
Install-Package Syncfusion.SfDiagram.WPF
```
Or install via the Visual Studio NuGet Package Manager UI. See [NuGet package guide](https://help.syncfusion.com/wpf/visual-studio-integration/nuget-packages) for details.
### License Key Registration
Starting with v16.2.0.x, a license key is required:
```csharp
// In App.xaml.cs, before InitializeComponent()
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR_LICENSE_KEY");
```
See [licensing overview](https://help.syncfusion.com/common/essential-studio/licensing/overview).
## Adding SfDiagram to Your Project
### Via XAML
1. Add the assembly reference: `Syncfusion.SfDiagram.WPF`
2. Add the namespace and declare the control:
```xaml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
x:Class="MyApp.MainWindow">
<Grid>
<syncfusion:SfDiagram x:Name="diagram">
<syncfusion:SfDiagram.Nodes>
<syncfusion:NodeCollection/>
</syncfusion:SfDiagram.Nodes>
<syncfusion:SfDiagram.Connectors>
<syncfusion:ConnectorCollection/>
</syncfusion:SfDiagram.Connectors>
</syncfusion:SfDiagram>
</Grid>
</Window>
```
### Via Code-Behind (C#)
```csharp
using Syncfusion.UI.Xaml.Diagram;
SfDiagram diagram = new SfDiagram();
diagram.Nodes = new NodeCollection();
diagram.Connectors = new ConnectorCollection();
RootGrid.Children.Add(diagram);
```
## Merging Built-In Shape Resources
SfDiagram ships with a built-in shapes resource dictionary. Merge it before using shape keys like `"Ellipse"`, `"Rectangle"`, `"PredefinedProcess"`:
```xaml
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BasicShapes.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
```
## Basic Diagram Elements
| Element | Class | Purpose |
|---------|-------|---------|
| Node | `NodeViewModel` | Visual shapes (rectangles, ellipses, custom) |
| Connector | `ConnectorViewModel` | Lines linking nodes or points |
| Annotation | `AnnotationEditorViewModel` | Text labels on nodes/connectors |
| Port | `NodePortViewModel` | Fixed connection points on nodes |
## Complete Minimal Flowchart Example
```xaml
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BasicShapes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--Shape style-->
<Style x:Key="ShapeStyle" TargetType="Path">
<Setter Property="Fill" Value="#FF5B9BD5"/>
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Stroke" Value="#FFEDF1F6"/>
</Style>
<!--Connector style-->
<Style TargetType="syncfusion:Connector">
<Setter Property="TargetDecoratorStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="Black"/>
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Height" Value="10"/>
<Setter Property="Width" Value="10"/>
</Style>
</Setter.Value>
</Setter>
</Style>
<syncfusion:SfDiagram x:Name="diagram">
<syncfusion:SfDiagram.Nodes>
<syncfusion:NodeCollection>
<syncfusion:NodeViewModel ID="Start" OffsetX="300" OffsetY="80"
UnitWidth="120" UnitHeight="40"
Shape="{StaticResource Ellipse}"
ShapeStyle="{StaticResource ShapeStyle}">
<syncfusion:NodeViewModel.Annotations>
<syncfusion:AnnotationCollection>
<syncfusion:AnnotationEditorViewModel Content="Start"/>
</syncfusion:AnnotationCollection>
</syncfusion:NodeViewModel.Annotations>
</syncfusion:NodeViewModel>
<syncfusion:NodeViewModel ID="Process" OffsetX="300" OffsetY="180"
UnitWidth="120" UnitHeight="60"
Shape="{StaticResource PredefinedProcess}"
ShapeStyle="{StaticResource ShapeStyle}">
<syncfusion:NodeViewModel.Annotations>
<syncfusion:AnnotationCollection>
<syncfusion:AnnotationEditorViewModel Content="Process"/>
</syncfusion:AnnotationCollection>
</syncfusion:NodeViewModel.Annotations>
</syncfusion:NodeViewModel>
<syncfusion:NodeViewModel ID="End" OffsetX="300" OffsetY="290"
UnitWidth="40" UnitHeight="40"
Shape="{StaticResource Ellipse}"
ShapeStyle="{StaticResource ShapeStyle}">
<syncfusion:NodeViewModel.Annotations>
<syncfusion:AnnotationCollection>
<syncfusion:AnnotationEditorViewModel Content="End"/>
</syncfusion:AnnotationCollection>
</syncfusion:NodeViewModel.Annotations>
</syncfusion:NodeViewModel>
</syncfusion:NodeCollection>
</syncfusion:SfDiagram.Nodes>
<syncfusion:SfDiagram.Connectors>
<syncfusion:ConnectorCollection>
<syncfusion:ConnectorViewModel SourceNodeID="Start" TargetNodeID="Process"/>
<syncfusion:ConnectorViewModel SourceNodeID="Process" TargetNodeID="End"/>
</syncfusion:ConnectorCollection>
</syncfusion:SfDiagram.Connectors>
</syncfusion:SfDiagram>
```
## Theming
Apply Syncfusion themes using the `SfSkinManager`:
```xaml
<syncfusion:SfDiagram syncfusion:SfSkinManager.Theme="{syncfusion:SkinManagerExtension ThemeName=FluentLight}"/>
```
## Common Gotchas
- **Nodes not visible:** Ensure you've merged `BasicShapes.xaml` before referencing shape keys.
- **License warning on startup:** Register the license key before `InitializeComponent()` in `App.xaml.cs`.
- **NodeCollection null:** Always initialize `diagram.Nodes = new NodeCollection()` before adding nodes in code.
## Related
- Adding nodes with shapes → `references/nodes.md`
- Adding connectors → `references/connectors.md`
- Applying automatic layouts → `references/automatic-layouts.md`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |