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#
Copy Code
|
|---|
using MindFusion.Diagramming.Mvc; |
In the body of the Index method, create a DiagramView instance and store it in the ViewData:
C#
Copy Code
|
|---|
DiagramView view = new DiagramView("diagramView1"); |
In Index.cshtml, add a reference to the MindFusion.Diagramming.Mvc namespace:
Razor
Copy Code
|
|---|
@using MindFusion.Diagramming.Mvc |
If you want to use tag helpers for adding MindFusion components to views, import them with the @addTagHelper directive:
Razor
Copy Code
|
|---|
@addTagHelper *, MindFusion.Diagramming.Mvc |
Add the component by using either the DiagramView HTML helper:
Razor
Copy Code
|
|---|
@Html.DiagramView( |
or alternatively using its Tag helper:
Razor
Copy Code
|
|---|
<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#
Copy Code
|
|---|
// 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#
Copy Code
|
|---|
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.