Shapes in WPF Diagram (SfDiagram)
11 Jan 202420 minutes to read
We have provided some basic built-in shapes as ResourceDictionary.
The following code example illustrates how to merge shapes into diagram.
<ResourceDictionary.MergedDictionaries>
<!--Initialize Shapes-->
<ResourceDictionary Source="/Syncfusion.SfDiagram.Wpf;component/Resources/BasicShapes.xaml" />
</ResourceDictionary.MergedDictionaries>
Basic Shapes
The following code example illustrates how to assign Shape
property of the Node
.
<!--Style for Node-->
<Style TargetType="syncfusion:Node">
<Setter Property="ShapeStyle">
<Setter.Value>
<Style TargetType="Path">
<Setter Property="Fill" Value="CornflowerBlue"/>
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Stroke" Value="Black"/>
</Style>
</Setter.Value>
</Setter>
</Style>
<!--Initialize the SfDiagram-->
<syncfusion:SfDiagram x:Name="diagram">
<!--Initialize the NodeCollection-->
<syncfusion:SfDiagram.Nodes>
<syncfusion:NodeCollection>
<!--Add Node with basic shape-->
<syncfusion:NodeViewModel x:Name="Node" UnitHeight="100" UnitWidth="100"
OffsetX="100" OffsetY="100"
Shape="{StaticResource Rectangle}"/>
</syncfusion:NodeCollection>
</syncfusion:SfDiagram.Nodes>
</syncfusion:SfDiagram>
//Initialize the diagram
SfDiagram diagram = new SfDiagram();
//Initialize the NodeViewModel
NodeViewModel node = new NodeViewModel()
{
UnitHeight = 100,
UnitWidth = 100,
OffsetX = 100,
OffsetY = 100,
Shape = new RectangleGeometry() { Rect = new Rect(0, 0, 10, 10) },
};
// Add the node into Nodes collection
(diagram.Nodes as NodeCollection).Add(node);
Output Node will be,
The list of shapes are available in the resource dictionary as follows
Shape Category | Shape Name | Output Shape |
---|---|---|
Basic Shapes | Rectangle | |
Triangle | ||
Plus | ||
Pentagon | ||
Hexagon | ||
Heptagon | ||
Octagon | ||
Trapezoid | ||
Decagon | ||
RightTriangle | ||
Cylinder | ||
Diamond | ||
TwoSideFlatCorner | ||
TwoSideRoundCorner | ||
RoundedRectangle | ||
Cloud | ||
CloudCallOut | ||
Paralleogram | ||
Frame | ||
Donut | ||
RectangleCallOut | ||
RoundedRectangleCallOut | ||
OvalCallOut | ||
Cube | ||
NoSymbol | ||
FourPointStar | ||
FivePointStar | ||
SixPointStar | ||
SevenPointStar | ||
SixteenPointStar | ||
TwentyFourPointStar | ||
ThirtyTwoPointStar | ||
Flow Shapes | Process | |
Decision | ||
Terminator | ||
Sort | ||
Document | ||
MultiDocument | ||
DirectData | ||
SequentialData | ||
PaperTap | ||
Collate | ||
SummingJunction | ||
Or | ||
InternalStorage | ||
PredefinedProcess | ||
Extract | ||
Merge | ||
OffPageReference | ||
SequentialAccessStorage | ||
Delay | ||
StoredData | ||
Display | ||
ManualOperation | ||
Data | ||
OnPageReference | ||
Prepration | ||
PunchedCard | ||
Card | ||
LoopLimit | ||
ManualInput | ||
Arrow Shapes | CurvedDownArrow | |
CurvedLeftArrow | ||
CurvedRightArrow | ||
CurvedUpArrow | ||
CircularArrow | ||
JumpingLeftArrow | ||
JumpingRightArrow | ||
UTurnArrow | ||
LeftArrow | ||
RightArrow | ||
DoubleArrow | ||
TopArrow | ||
BottomArrow | ||
MultiArrow | ||
BlockArrow | ||
QuadBlockArrow | ||
NotchedArrow | ||
LeftRightBlockArrow | ||
QuadArrow | ||
FlexibleArrow | ||
Data Flow Shapes | OvalProcess | |
ExternalIndicator | ||
Object | ||
MultipleProcess | ||
State | ||
Stop1 | ||
Entity1 | ||
Entity2 | ||
Electrical Shapes | Resistor | |
Capacitor | ||
AC | ||
Dc1 | ||
EquiPotent | ||
Inductor | ||
Crystal | ||
Attenuator | ||
Antenna | ||
LoopAntenna | ||
CircuitBreaker | ||
Fuse | ||
IdealSource | ||
GenericComponent | ||
Transducer | ||
Transducer2 | ||
PickupHead | ||
HalfConductor | ||
Pulse | ||
Pulse1 | ||
Sawtooth | ||
Step | ||
SensingLinkSquib | ||
Indicator | ||
Material | ||
DelayElement | ||
SurgeProtector | ||
SurgeProtector1 | ||
PermanentMagnet | ||
Magnetoresistor_shape | ||
IgnitorPlug | ||
Bell | ||
Buzzer | ||
ThermalElement | ||
ThermoCouple |
Find the Shapes sample to depict the shapes.