An unbound FlexDiagram is created programmatically without using data binding. Nodes and edges are manually defined and added to the diagram.
This approach is suitable for:
| C# |
コードのコピー
|
|---|---|
var startNode = new Node() { Text = "Start Process" }; var processNode = new Node() { Text = "Execute", Shape = Shape.RoundedRectangle }; var endNode = new Node() { Text = "Complete" }; |
|
| C# |
コードのコピー
|
|---|---|
diagram.Nodes.Add(startNode);diagram.Nodes.Add(processNode); diagram.Nodes.Add(endNode); |
|
| C# |
コードのコピー
|
|---|---|
diagram.Edges.Add(new Edge() { Source = startNode, Target = processNode, TargetArrow = ArrowStyle.Normal }); diagram.Edges.Add(new Edge() { Source = processNode, Target = endNode, TargetArrow = ArrowStyle.Normal }); |
|
| C# |
コードのコピー
|
|---|---|
diagram.Direction = DiagramDirection.TopBottom; |
|
| XAML |
コードのコピー
|
|---|---|
<Window x:Class="FlexDiagram_WPF.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Unbound FlexDiagram" Height="450" Width="800"> <Grid> <c1:FlexDiagram x:Name="diagram" ScaleMode="ScaleToFit"/> </Grid> </Window> |
|
| C# |
コードのコピー
|
|---|---|
using C1.Diagram; using C1.WPF.Diagram; using System.Windows; namespace FlexDiagram_WPF { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Loaded += (s, e) => InitializeDiagram(); } private void InitializeDiagram() { // Layout direction diagram.Direction = DiagramDirection.TopBottom; // Create nodes var startNode = new Node() { Text = "Start Process", Tooltip = "Start Node" }; var processNode = new Node() { Text = "Execute", Shape = Shape.RoundedRectangle, Tooltip = "Processing Step" }; var endNode = new Node() { Text = "Complete", Tooltip = "End Node" }; // Add nodes diagram.Nodes.Add(startNode); diagram.Nodes.Add(processNode); diagram.Nodes.Add(endNode); // Create edges diagram.Edges.Add(new Edge() { Source = startNode, Target = processNode, TargetArrow = ArrowStyle.Normal, Tooltip = "Start → Execute" }); diagram.Edges.Add(new Edge() { Source = processNode, Target = endNode, TargetArrow = ArrowStyle.Normal, Tooltip = "Execute → End" }); // Optional refresh diagram.Invalidate(); } } } |
|