Easily Prepare Network Diagrams with Our WPF Diagram Control | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Easily Prepare Network Diagrams with Our WPF Diagram Control

Easily Prepare Network Diagrams with Our WPF Diagram Control

Do you have an application requirement to draw network diagrams? Are you looking for a network diagram designer? Designing your own network architecture diagram is faster and easier with a network diagram creator application built using our WPF Diagram control.

In this blog post, you will learn how to create your own network architecture diagram quickly and easily using an interactive user interface that supports drag-and-drop operations, copy, paste, import, export, pan, zoom, and more. We will see much of the rich feature set available in our WPF Diagram control that provides an excellent, intuitive user experience.

Preparing Network Diagrams with Our WPF Diagram Control
Preparing Network Diagrams with Our WPF Diagram Control

What is a network diagram?

A network diagram is a graphical representation of network architecture. It shows how computers and network devices (e.g., routers, hubs, switches, firewalls, etc.) are connected within a network and displays how information flows through it. This visual representation helps to track down network issues by studying how the devices are connected and interrelated.

Network diagram symbols

Since a network diagram is a graphical representation of an actual system, it relies on symbols to convey the meaning. The network diagram may include hundreds of different symbols. The standard network diagram symbols include firewall, server, mainframe, PC, laptop, switch, hub, router, cell phone, and more.

Common Network Diagram Symbols
Common Network Diagram Symbols

Creating reusable network diagram symbols

The WPF Diagram control provides a gallery of reusable symbols and diagram elements, called a stencil. The symbols can be dragged onto the diagramming page any number of times and in any place.

Let’s see how to create a stencil with our network diagram symbols. The stencil’s SymbolSource property is used to define the data source as a collection of objects (symbol, node, connector, etc.) that needs to be populated as symbols. The following code creates a stencil with network diagram symbols.

XAML:

<stencil:Stencil x:Name="stencil" 
      Grid.Row="1"   
   ExpandMode="ZeroOrMore"
      SymbolFilters="{Binding Symbolfilters}" SelectedFilter="{Binding Selectedfilter}">
  <stencil:Stencil.SymbolSource>
    <local:SymbolCollection>
       <!--Computers and Monitors-->
        <viewmodel:CustomNode Name="PC" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource PCStencil}" Key="Computers and Monitors">
          <!--Initialize the annotations-->
          <Syncfusion:NodeViewModel.Annotations>
             <!--Initialize the AnnotationCollection-->
             <Syncfusion:AnnotationCollection>
                 <!--Initialize the Annotation editor view model-->
                 <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
              </Syncfusion:AnnotationCollection>
          </Syncfusion:NodeViewModel.Annotations>
        </viewmodel:CustomNode>
      <viewmodel:CustomNode Name="VirtualPC" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource VirtualPCStencil}" Key="Computers and Monitors">
        <Syncfusion:NodeViewModel.Annotations>
           <!--Initialize the AnnotationCollection-->
           <Syncfusion:AnnotationCollection>
             <!--Initialize the Annotation editor view model-->
             <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
           </Syncfusion:AnnotationCollection>
        </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
     <viewmodel:CustomNode Name="Terminal" UnitHeight="150" UnitWidth="130" ContentTemplate="{StaticResource TerminalStencil}" Key="Computers and Monitors">
      <Syncfusion:NodeViewModel.Annotations>
       <!--Initialize the AnnotationCollection-->
       <Syncfusion:AnnotationCollection>
         <!--Initialize the Annotation editor view model-->
         <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
        </Syncfusion:AnnotationCollection>
       </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
    <viewmodel:CustomNode Name="Wavelength" UnitHeight="140" UnitWidth="150" ContentTemplate="{StaticResource WavelengthStencil}" Key="Computers and Monitors">
     <Syncfusion:NodeViewModel.Annotations>
      <!--Initialize the AnnotationCollection-->
      <Syncfusion:AnnotationCollection>
        <!--Initialize the Annotation editor view model-->
        <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,35,0,0"/>
       </Syncfusion:AnnotationCollection>
      </Syncfusion:NodeViewModel.Annotations>
     </viewmodel:CustomNode>
   <viewmodel:CustomNode Name="DataPipe" UnitHeight="80" UnitWidth="120" ContentTemplate="{StaticResource DataPipeStencil}" Key="Computers and Monitors">
    <Syncfusion:NodeViewModel.Annotations>
     <!--Initialize the AnnotationCollection-->
     <Syncfusion:AnnotationCollection>
       <!--Initialize the Annotation editor view model-->
       <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,30,0,0"/>
      </Syncfusion:AnnotationCollection>
     </Syncfusion:NodeViewModel.Annotations>
    </viewmodel:CustomNode>
   <viewmodel:CustomNode Name="SlateDevice" UnitHeight="100" UnitWidth="130" ContentTemplate="{StaticResource SlateDivceStencil}" Key="Computers and Monitors">
    <Syncfusion:NodeViewModel.Annotations>
      <!--Initialize the AnnotationCollection-->
      <Syncfusion:AnnotationCollection>
        <!--Initialize the Annotation editor view model-->
        <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
       </Syncfusion:AnnotationCollection>
      </Syncfusion:NodeViewModel.Annotations>
     </viewmodel:CustomNode>
    <viewmodel:CustomNode Name="TabletDevice" UnitHeight="130" UnitWidth="130" ContentTemplate="{StaticResource TabletDeviceStencil}" Key="Computers and Monitors">
     <Syncfusion:NodeViewModel.Annotations>
       <!--Initialize the AnnotationCollection-->
       <Syncfusion:AnnotationCollection>
          <!--Initialize the Annotation editor view model-->
          <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
         </Syncfusion:AnnotationCollection>
       </Syncfusion:NodeViewModel.Annotations>
      </viewmodel:CustomNode>
     <viewmodel:CustomNode Name="Laptop" UnitHeight="140" UnitWidth="100" ContentTemplate="{StaticResource LaptopStencil}" Key="Computers and Monitors">
      <Syncfusion:NodeViewModel.Annotations>
        <!--Initialize the AnnotationCollection-->
        <Syncfusion:AnnotationCollection>
           <!--Initialize the Annotation editor view model-->
           <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
          </Syncfusion:AnnotationCollection>
         </Syncfusion:NodeViewModel.Annotations>
        </viewmodel:CustomNode>
      <viewmodel:CustomNode Name="PDA" UnitHeight="150" UnitWidth="70" ContentTemplate="{StaticResource PDAStencil}" Key="Computers and Monitors">
        <Syncfusion:NodeViewModel.Annotations>
          <!--Initialize the AnnotationCollection-->
          <Syncfusion:AnnotationCollection>
            <!--Initialize the Annotation editor view model-->
            <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
           </Syncfusion:AnnotationCollection>
          </Syncfusion:NodeViewModel.Annotations>
         </viewmodel:CustomNode>
        <viewmodel:CustomNode Name="CRTMonitor" UnitHeight="140" UnitWidth="120" ContentTemplate="{StaticResource CRTMonitorStencil}" Key="Computers and Monitors">
         <Syncfusion:NodeViewModel.Annotations>
          <!--Initialize the AnnotationCollection-->
          <Syncfusion:AnnotationCollection>
             <!--Initialize the Annotation editor view model-->
             <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
            </Syncfusion:AnnotationCollection>
           </Syncfusion:NodeViewModel.Annotations>
          </viewmodel:CustomNode>
        <viewmodel:CustomNode Name="LCDMonitor" UnitHeight="140" UnitWidth="130" ContentTemplate="{StaticResource LCDMonitorStencil}" Key="Computers and Monitors">
         <Syncfusion:NodeViewModel.Annotations>
           <!--Initialize the AnnotationCollection-->
           <Syncfusion:AnnotationCollection>
              <!--Initialize the Annotation editor view model-->
              <Syncfusion:AnnotationEditorViewModel Constraints="Editable,Selectable,Resizable,Draggable" Margin="0,60,0,0"/>
             </Syncfusion:AnnotationCollection>
            </Syncfusion:NodeViewModel.Annotations>
           </viewmodel:CustomNode>
          <viewmodel:CustomNode Name="Connector" UnitHeight="170" UnitWidth="130" ContentTemplate="{StaticResource DynamicConnectorStencil}" Key="Computers and Monitors">
          </viewmodel:CustomNode>
         </local:SymbolCollection>
        </stencil:Stencil.SymbolSource>
         <stencil:Stencil.SymbolGroups>
           <stencil:SymbolGroups>
              <!--Separate groups based on the key-->
              <stencil:SymbolGroupProvider MappingName="Key"/>
           </stencil:SymbolGroups>
      </stencil:Stencil.SymbolGroups>
    </stencil:Stencil>

The following screenshot shows the collection of network diagram symbols in the created stencil.

Network Diagram Symbol Stencil
Network Diagram Symbol Stencil

You can refer to this stencil documentation page for details about adding and grouping symbols, plus customizing the stencil appearance.

Creating a diagramming page

Now, we have set up reusable network diagram shapes in our Stencil. Using the following code example, let’s add the diagramming page we’ll create our network diagram on.

XAML:

<Syncfusion:SfDiagram x:Name="Diagram" Grid.Column="1"
        DefaultConnectorType="{Binding DefaultConnectorType,Mode=TwoWay}"
        PortVisibility="{Binding PortVisibility}"
        Nodes="{Binding Nodes}"
        Connectors="{Binding Connectors}"
        ScrollSettings="{Binding ScrollSettings}"
        PageSettings="{Binding PageSettings}"
        VerticalRuler="{Binding VerticalRuler}"
        HorizontalRuler="{Binding HorizontalRuler}"
        PrintingService="{Binding PrintingService}"
        Constraints="{Binding Constraints}"
        Tool="{Binding Tool,Mode=TwoWay}"
        DrawingTool="{Binding DrawingTool,Mode=TwoWay}"
        SelectedItems="{Binding SelectedItems}"
        ExportSettings="{Binding ExportSettings}"
        SnapSettings="{Binding SnapSettings}"
        DragEnterCommand="{Binding DragEnterCommand}"
        DragOverCommand="{Binding DragOverCommand}"
        ItemAddedCommand="{Binding ItemAddedCommand}"
        DropCommand="{Binding DropCommand}"
        ItemSelectedCommand="{Binding ItemSelectedCommand}"
        ItemUnSelectedCommand="{Binding ItemUnSelectedCommand}"
        ViewPortChangedCommand="{Binding ViewPortChangedCommand}"
        AnnotationConstraints="{Binding AnnotationConstraints}"
        Loaded="Diagram_Loaded">
</Syncfusion:SfDiagram>

The following screenshot shows the created diagramming page along with the network diagram symbols stencil.

Diagramming Page with Stencil
Diagramming Page with Stencil

You can refer to this Diagram documentation page for more details on how to add a diagramming page in your application and how to customize its appearance.

How to create a network diagram

Now you can easily draw a network diagram by dragging and dropping the network diagram symbols from the stencil, arranging them on the page, and connecting them.

Add network diagram symbols

Start by dragging the symbols you need for each device onto the diagramming page from the Computers and Monitors and Network and Peripherals stencils. Arrange them in an order that makes it clear where the network origin and end points are, and how the various nodes are linked. People who read the diagram should be able to see where to start, and how to follow the connections.
Add network diagram symbols

Add connections between devices

Each diagram symbol has Draw quick command which is visible when the symbol is selected. This quick command creates a connection from the symbol by clicking and dragging the connector and dropping it on another symbol.
Add connections between devices

You can refer to this quick command documentation page for more details on how to add or remove default and custom quick commands in your application and how to customize their appearance.

You can also create connectors by selecting the connector tool  connector tool   from the toolbar or from the Tools > Connector tool menu option. Now, click a symbol and drag a connector to another shape. When you are done, click the pointer tool  pointer tool  on the toolbar to select the symbols.
Add connections between devices

Refer to the tools documentation page for more details about supported diagram tools.

Change connection line style

The WPF Diagram control provides three different types of connection lines: straight, orthogonal, and Bezier. You can change the connector type of a connector by selecting it and using the change connector type   change connector type  drop-down in the toolbar, or by using the Tools > Connectors menu option.
Change connection line style

Refer to the connector types documentation page for more details on different types of connectors and how to change them in your application.

Add labels and data

To add text to a network symbol, double-click the symbol and start typing. To move the text, click and drag the text to the desired position.
Add labels and data

Refer to annotation documentation page for more details on how to add labels in your application and customize their appearance.

Loading and saving a diagram

The Diagram control provides the flexibility to save your current work and resume it later by loading the saved diagram back to the diagram canvas. You can use Save button  Savebutton to save your current diagram to the local drive and use the Open button Open button to load an existing diagram file from your local drive.
Loading and saving a diagram

Refer to the load and save documentation pages for more details on how to integrate the WPF Diagram control’s load and save functionality in your application.

Print and export diagram

Once you have finished editing the network diagram, you can export it as an image or PDF document, or you can print it using a printer.

Print a diagram

You can print a diagram directly by clicking the Print button  Print button in the toolbar or by selecting the File > Print menu option.

The following screenshot shows the Print Diagram dialog box along with the custom print options.

Diagram Print Options
Diagram Print Options

Refer to the printing documentation page for more details on how to configure diagram printing functionality in your application.

Export a diagram

You can save a diagram in PDF format, or you can save it as an image file (JPEG, PNG, BMP, TIF, GIF, and more). You can do this by clicking the Export button  export button  or selecting the File > Export menu option.
Export a diagram

Refer to the exporting documentation page for more details on how to configure diagram exporting functionality in your application.

Pan and zoom

The WPF Diagram control provides support to pan and zoom the diagram in different ways.

Pan and zoom using the keyboard

  1. Hold down the Ctrl and Shift keys. The pointer will turn into a magnifying glass.
  2. Try the following techniques:
  • Click the left mouse button to enlarge the view.
  • Click the right mouse button to reduce the view.
  • Click the left mouse button and drag a rectangle that contains a region you want to zoom into.
  • Right-click and drag to pan the diagram.

Pan and zoom using the keyboard

Pan and zoom using the scroll wheel

Do any of the following:

  • To scroll up or down, rotate the scroll wheel forward or backward.
  • To scroll left or right, hold down Shift as you rotate the scroll wheel forward or backward.
  • To zoom in or out, hold down Ctrl as you rotate the scroll wheel forward or backward.

Pan and zoom using the scroll wheelZoom using the zoom controls

The zoom controls are in the status bar, below the diagramming page.

Clicking the zoom out and zoom in buttons change the zoom level of the diagram. The controls include a slider that sets the zoom level and a button to fit the page to the size of the current window.
Zoom by using the Zoom controls

Pan using the pan tool

You can pan the diagram by selecting the Pan tool  Pan tool  from the toolbar or the Tools > Pan menu option and then clicking and dragging the mouse to pan the diagram.
Pan using the pan tool

Resources

You can download the source project for this network diagram designer from this GitHub location.

Conclusion

In this blog post, you have seen how to create a network diagram easily using a network diagram designer application that was created using the Syncfusion WPF Diagram library. Also, you have learned about connectors and labels, and about performing operations such as load, save, export, print, pan, and zoom with the created network diagram.

Similarly, you can create your own diagram creation application like an organization chart creator, a flow chart creator, or a logic circuit diagram using the Syncfusion WPF Diagram library. The library supports even more rich interactive features than just those demonstrated here, automatic layouts, and data binding from different data sources. To explore features in more depth, refer to our documentation.

If you’re already a Syncfusion user, you can download the product setup from our website. Otherwise, you can download a free, 30-day trial here.

If you have any questions, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed