Getting Started with Blazor GanttChart

18 Nov 20188 minutes to read

This section explains you through the step-by-step process of integrating the Syncfusion® Blazor Gantt Chart component into your Blazor MAUI application using both Visual Studio and Visual Studio Code.

Ready to streamline your Syncfusion® Blazor development?
Discover the full potential of Syncfusion® Blazor components with Syncfusion® AI Coding Assistants. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like VS Code, Cursor, Syncfusion® CodeStudio and more. Explore Syncfusion® AI Coding Assistants

Prerequisites

To use the MAUI project templates, install the Mobile development with the .NET extension for Visual Studio. For more details, refer to here or the Syncfusion® Blazor Extension.

Create a new Blazor MAUI app

Create a Blazor MAUI App using Visual Studio via Microsoft Templates. For detailed instructions, refer to the Blazor MAUI App Getting Started documentation.

Install Syncfusion® Blazor packages

Install Syncfusion.Blazor.Gantt and Syncfusion.Blazor.Themes NuGet packages in your project using the NuGet Package Manager.

  1. Go to Tools → NuGet Package Manager → Manage NuGet Packages for Solution
  2. Search for Syncfusion.Blazor.Gantt and install the latest version
  3. Search for Syncfusion.Blazor.Themes and install the latest version

Alternatively, run the following commands in the Package Manager Console:

Install-Package Syncfusion.Blazor.Gantt -Version 34.1.29
Install-Package Syncfusion.Blazor.Themes -Version 34.1.29

Prerequisites

To use the MAUI project templates, install the Mobile development with the .NET extension for Visual Studio Code. For more details, refer to here or the Syncfusion® Blazor Extension.

Create a new Blazor MAUI app

Create a Blazor MAUI app using Visual Studio Code via Microsoft Templates or the Syncfusion® Blazor Extension. For detailed instructions, refer to the Blazor MAUI App Getting Started documentation.

Alternatively, create a MAUI application by using the following command in the integrated terminal (Ctrl+`):

dotnet new maui-blazor -o MauiBlazorApp
cd MauiBlazorApp

Install Syncfusion® Blazor packages

Install Syncfusion.Blazor.Gantt and Syncfusion.Blazor.Themes NuGet packages in your project using the integrated terminal.

Run the following commands in the integrated terminal (Ctrl+`):

dotnet add package Syncfusion.Blazor.Gantt --version 34.1.29
dotnet add package Syncfusion.Blazor.Themes --version 34.1.29

NOTE

All Syncfusion Blazor packages are available on nuget.org. See the NuGet packages topic for details.

Register Syncfusion® Blazor service

Register the Syncfusion® Blazor service in the ~/MauiProgram.cs file.

....
using Syncfusion.Blazor;

....

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        ....
        builder.Services.AddSyncfusionBlazor();
        ....
    }
}

Add stylesheet and script resources

The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet and script references in the ~/index.html file.

  • Add the stylesheet reference inside the <head> tag of the index.html file.
  • Add the script reference inside the <body> tag of the index.html file.
<link href="_content/Syncfusion.Blazor.Themes/fluent2.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>

NOTE

Check out the Blazor Themes topic to discover various methods (Static Web Assets, CDN, and CRG) for referencing themes in your Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in your Blazor application.

Add Syncfusion® Blazor Gantt Chart component

Add the Syncfusion® Blazor Gantt Chart component in the ~/Pages/Home.razor file.

@using Syncfusion.Blazor.Gantt

<SfGantt DataSource="@TaskCollection" Height="450px" Width="700px">
    <GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Duration="Duration" Progress="Progress" ParentID="ParentId">
    </GanttTaskFields>
</SfGantt>

@code {
    public List<TaskData>? TaskCollection { get; set; }
    protected override void OnInitialized()
    {
        TaskCollection = GetTaskCollection();
    }

    public class TaskData
    {
        public int TaskId { get; set; }
        public string? TaskName { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string? Duration { get; set; }
        public int Progress { get; set; }
        public int? ParentId { get; set; }
    }

    public static List<TaskData> GetTaskCollection()
    {
        List<TaskData> Tasks = new List<TaskData>()
        {
            new TaskData() { TaskId = 1, TaskName = "Project initiation", StartDate = new DateTime(2026, 01, 05), EndDate = new DateTime(2026, 01, 08), },
            new TaskData() { TaskId = 2, TaskName = "Identify Site location", StartDate = new DateTime(2026, 01, 05), Duration = "0", Progress = 30, ParentId = 1, },
            new TaskData() { TaskId = 3, TaskName = "Perform soil test", StartDate = new DateTime(2026, 01, 05), EndDate = new DateTime(2026, 01, 08), Progress = 40, ParentId = 1, },
            new TaskData() { TaskId = 4, TaskName = "Soil test approval", StartDate = new DateTime(2026, 01, 05), Duration = "0", Progress = 30, ParentId = 1, },
            new TaskData() { TaskId = 5, TaskName = "Project estimation", StartDate = new DateTime(2026, 01, 05), EndDate = new DateTime(2026, 01, 10), },
            new TaskData() { TaskId = 6, TaskName = "Develop floor plan for estimation", StartDate = new DateTime(2026, 01, 07), EndDate = new DateTime(2026, 01, 09), Progress = 30, ParentId = 5, },
            new TaskData() { TaskId = 7, TaskName = "List materials", StartDate = new DateTime(2026, 01, 07), EndDate = new DateTime(2026, 01, 09), Progress = 40, ParentId = 5, },
            new TaskData() { TaskId = 8, TaskName = "Estimation approval", StartDate = new DateTime(2026, 01, 07), Duration = "0", Progress = 30, ParentId = 5, }
        };
        return Tasks;
    }
}

Run the application

Visual Studio:

  • Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the .NET MAUI Blazor Hybrid app.
    The application will open as a native app.

How to run the sample on Windows

Run the sample in Windows Machine mode, and it will run Blazor MAUI in Windows.

Blazor Gantt Chart Component

How to run the sample on Android

Run the sample in Android Emulator mode, and it will launch the Blazor MAUI application on the configured Android virtual device.

Blazor Gantt Chart Component

To run the Blazor Gantt Chart in a Blazor Android MAUI application using the Android emulator, follow these steps:

Refer here to install and launch Android emulator.

NOTE

If encounter any errors while using the Android Emulator, refer to the following link for troubleshooting guidance Troubleshooting Android Emulator.

See also