After adding the nuget package, you should be able to add a DiagramView component to your ASP.NET Razor Pages user interface.
In Index.cshtml.cs, add a reference to the MindFusion.Diagramming.Mvc namespace:
C#
![]() |
---|
using MindFusion.Diagramming.Mvc; |
In the body of the Index method, create a DiagramView instance and store it in the ViewData:
C#
![]() |
---|
DiagramView view = new DiagramView("diagramView1"); |
In Index.cshtml, add a reference to the MindFusion.Diagramming.Mvc namespace:
Razor
![]() |
---|
@using MindFusion.Diagramming.Mvc |
If you want to use tag helpers for adding MindFusion components to views, import them with the @addTagHelper directive:
Razor
![]() |
---|
@addTagHelper *, MindFusion.Diagramming.Mvc |
Add the component by using either the DiagramView HTML helper:
Razor
![]() |
---|
@Html.DiagramView( |
or alternatively using its Tag helper:
Razor
![]() |
---|
<mindfusion-diagramview |
You can create nodes and links programmatically either by calling Factory methods, or by instantiating objects of respective class and adding them to Items collection:
C#
![]() |
---|
// in controller |
The DiagramView component can preserve its data between postbacks by serializing and deserializing to JSON internally. Call the static FromRequest method from the page's OnPost method to get this functionality.
C#
![]() |
---|
public void OnPost() |
Browse the other sections of this help file to learn more about the functionality provided by the MindFusion.Diagramming classes, methods and properties. Follow the tutorials to learn how to populate the diagram model programmatically or create custom item types.