Get Started

Add FlexCore to your own Blazor app: install the package, add the namespaces, register the dialog and toast services and mount their hosts, turn on interactivity, and put a first grid on a page. Want a working app first? The Quick Start download is the home page's Razor Sharp Getaways as a complete project.

Install

From NuGet:

dotnet add package FlexCore

Or as a project reference (during development):

<ProjectReference Include="..\path\to\FlexCore\FlexCore.csproj" />

Source: github.com/wadoodachaudhary/FlexCore

Icons: the report writer's toolbar uses Bootstrap Icons class names, and the examples on this site pass bi-* classes to IconCss; link the Bootstrap Icons stylesheet in App.razor if you use either.

License

The FlexCore package on NuGet is released under the MIT license. A Community edition is in preparation and will be delivered as a download link by email; sign up to receive it or to ask a question.

Add the namespaces

The controls live in Fx.ControlKit and its sub-namespaces. Add the ones you use to Components/_Imports.razor so every page sees them:

@using Fx.ControlKit
@using Fx.ControlKit.Grid
@using Fx.ControlKit.Charts
@using Fx.ControlKit.Layout
@using Fx.ControlKit.Navigation
@using Fx.ControlKit.Dialogs
@using Fx.ControlKit.Notifications

Fx.ControlKit holds the buttons, inputs, pickers, cards and tree view; .Grid the data grid, tree grid, pivot table and drop-down grid. Others: Fx.ControlKit.Maps, .Scheduling, .Gantt, .Diagram, .Editor, .Data, .Docking, .Reports and .AI; Fx.ControlKit.Pdf comes with the FlexCore.Documents package, which is not on NuGet yet: reference FlexCore.Documents/FlexCore.Documents.csproj from the repository. Every Razor tab on this site starts with the @using lines its example needs.

Register services

In Program.cs. These are the registrations this site uses (Program.cs in the Showcase repository):

using Fx.ControlKit.Dialogs;
using Fx.ControlKit.Notifications;

builder.Services.AddScoped<NotificationService>();                 // toasts
builder.Services.AddScoped<DialogService>();                       // confirm / alert / prompt
builder.Services.AddScoped<IDialogService>(sp => sp.GetRequiredService<DialogService>());
builder.Services.AddScoped<Fx.ControlKit.ZoomService>();           // optional: shared text zoom
// Report writer only: ReportOptions, CrystalXmlReportLoader and your own IReportDataExecutor,
// IReportSessionContext, IReportExporter, IReportPickListProvider and IReportViewerSettings
// (the Showcase Program.cs has a working set with stub adapters).

Mount the hosts

Toasts and service dialogs render through two host components. Put them once in your layout, or nothing will appear when you call NotificationService or IDialogService. In MainLayout.razor:

@using Fx.ControlKit.Dialogs
@using Fx.ControlKit.Notifications

<main>@Body</main>

<NotificationDisplayControl />
<DialogHostControl />

Controls load their own scripts and styles; there is nothing to add to App.razor beyond the usual Blazor script tag.

Turn on interactivity

The controls respond to clicks and typing only in an interactive render mode. A project made with dotnet new blazor already registers interactive server components in Program.cs; then either put @rendermode InteractiveServer at the top of each page that uses the controls, as this site does, or make the whole app interactive in App.razor:

<HeadOutlet @rendermode="InteractiveServer" />
...
<Routes @rendermode="InteractiveServer" />

Use a control

A whole page, Components/Pages/Tours.razor:

@page "/tours"
@rendermode InteractiveServer
@using Fx.ControlKit.Grid

<GridControl TValue="MyRow" DataSource="@rows"
             AllowSelection="true" AllowSorting="true"
             AllowFiltering="true" AllowGrouping="true">
    <GridColumnsBase>
        <GridColumn Field="Id"       HeaderText="ID"   Width="80px" />
        <GridColumn Field="Name"     HeaderText="Name" Width="200px" />
        <GridColumn Field="Quantity" HeaderText="Qty"  Width="100px"
                    Type="ColumnType.Number" Format="N0" TextAlign="TextAlign.Right" />
    </GridColumnsBase>
</GridControl>

@code {
    private readonly List<MyRow> rows =
    [
        new(1, "Old town walk", 12),
        new(2, "Sintra day trip", 8),
        new(3, "Sunset sail", 20),
    ];

    private sealed record MyRow(int Id, string Name, int Quantity);
}

Targets

  • .NET 10.0
  • Blazor Server (this site). Blazor WebAssembly has not been verified yet.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.