use-igniteui-blazor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApplication Setup & Component Registration
应用设置与组件注册
1. NuGet package
1. NuGet 包
Before adding packages, inspect the target projects' target framework and existing package references. The lowest supported target framework version is .NET 8.0. If or is already referenced, keep that package strategy and do not add Lite or GridLite. Only switch package families when the user explicitly asks, replacing conflicting references rather than keeping both.
IgniteUI.BlazorIgniteUI.Blazor.Trialbash
dotnet add package IgniteUI.Blazor.Lite # OSS core UI components (MIT)
dotnet add package IgniteUI.Blazor.GridLite # OSS lightweight grid (MIT)Use for core controls such as , and , and for the lightweight grid. Reference both packages only when the app needs both. Do not invent per-component packages such as .
IgniteUI.Blazor.LiteIgbInputIgbComboIgbDialogIgniteUI.Blazor.GridLiteIgniteUI.Blazor.ComboCharts, maps, gauges and other premium components are not included in Lite. Check the requested component's package before recommending a reference.
添加包之前,请检查目标项目的目标框架和现有包引用。最低支持的目标框架版本为 .NET 8.0。如果已引用 或 ,请保持该包策略,不要添加 Lite 或 GridLite。仅当用户明确要求时才切换包系列,需替换冲突的引用而非同时保留两者。
IgniteUI.BlazorIgniteUI.Blazor.Trialbash
dotnet add package IgniteUI.Blazor.Lite # OSS core UI components (MIT)
dotnet add package IgniteUI.Blazor.GridLite # OSS lightweight grid (MIT)IgniteUI.Blazor.LiteIgbInputIgbComboIgbDialogIgniteUI.Blazor.GridLiteIgniteUI.Blazor.Combo图表、地图、仪表及其他高级组件不包含在 Lite 版本中。推荐引用前请先确认所需组件所属的包。
2. IgniteUI.Blazor.Lite
Service Registration
IgniteUI.Blazor.Lite2. IgniteUI.Blazor.Lite
服务注册
IgniteUI.Blazor.LiteUsually in :
Program.cscsharp
builder.Services.AddIgniteUIBlazor(); // no modules pre-loaded; each loads on first renderPass values to eagerly pre-load a specific set instead:
typeof(Igb<Name>Module)csharp
builder.Services.AddIgniteUIBlazor(
typeof(IgbInputModule), typeof(IgbComboModule), typeof(IgbDialogModule));Module names always follow . Passing modules eagerly loads them during startup, increasing the initial transfer to reduce first-render latency. Components not listed still register their own modules on first render.
Igb{ComponentName}ModuleFor a GridLite-only setup, do not call or add manual Ignite UI script tags. Reference , add the control namespace, and link the GridLite stylesheet shown below.
AddIgniteUIBlazor()IgniteUI.Blazor.GridLiteSplit Blazor Web App: add each required package to both the Server and Client files. For core controls, use the actual project paths in place of these examples.
.csprojbash
dotnet add Server/Server.csproj package IgniteUI.Blazor.Lite
dotnet add Client/Client.csproj package IgniteUI.Blazor.LiteIf GridLite is needed, add to both projects as well. For a GridLite-only app, add only that package and skip the service registrations below.
IgniteUI.Blazor.GridLiteFor Lite, call in both the server and client .
AddIgniteUIBlazor()Program.cscsharp
// Server
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddIgniteUIBlazor();
// Client (WebAssemblyHostBuilder)
builder.Services.AddIgniteUIBlazor();For a single-project Interactive Server Blazor Web App, call once in the server . Do not add a client project or WebAssembly services.
AddIgniteUIBlazor()Program.cs通常在 中配置:
Program.cscsharp
builder.Services.AddIgniteUIBlazor(); // no modules pre-loaded; each loads on first render也可以传入 参数,主动预加载指定的模块集合:
typeof(Igb<Name>Module)csharp
builder.Services.AddIgniteUIBlazor(
typeof(IgbInputModule), typeof(IgbComboModule), typeof(IgbDialogModule));模块名称始终遵循 的格式。主动传入模块会在启动时加载它们,会增加初始传输量,但能减少首次渲染延迟。未列出的组件仍会在首次渲染时自行注册对应的模块。
Igb{组件名}Module对于仅使用 GridLite 的配置,请勿调用 或手动添加 Ignite UI 脚本标签。只需引用 、添加控件命名空间,并链接下文所示的 GridLite 样式表即可。
AddIgniteUIBlazor()IgniteUI.Blazor.GridLite拆分式 Blazor Web App: 将所需的每个包都添加到 Server 和 Client 两个项目的 文件中。对于核心控件,请使用实际项目路径替换示例中的路径。
.csprojbash
dotnet add Server/Server.csproj package IgniteUI.Blazor.Lite
dotnet add Client/Client.csproj package IgniteUI.Blazor.Lite如果需要 GridLite,也请将 添加到两个项目中。对于仅使用 GridLite 的应用,只需添加该包,跳过下方的服务注册步骤。
IgniteUI.Blazor.GridLite对于 Lite 版本,请在服务端和客户端的 中都调用 。
Program.csAddIgniteUIBlazor()csharp
// Server
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddIgniteUIBlazor();
// Client (WebAssemblyHostBuilder)
builder.Services.AddIgniteUIBlazor();对于单项目的交互服务端 Blazor Web App,只需在服务端的 中调用一次 即可。无需添加客户端项目或 WebAssembly 相关服务。
Program.csAddIgniteUIBlazor()3. _Imports.razor
_Imports.razor3. _Imports.razor
_Imports.razorrazor
@using IgniteUI.Blazor.ControlsAdd it to both files in split Blazor Web App solutions.
_Imports.razorrazor
@using IgniteUI.Blazor.Controls在拆分式 Blazor Web App 解决方案中,请将该语句添加到两个 文件中。
_Imports.razor4. Host page — theme stylesheet
4. 宿主页面 — 主题样式表
Host page is (WASM/MAUI), (Server), or (Web App).
wwwroot/index.htmlPages/_Host.cshtmlComponents/App.razorIgniteUI.Blazor.Litehtml
<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />The stylesheet is required: without it components render unstyled.
Theme files under are — link exactly one.
_content/IgniteUI.Blazor/themes/{light|dark}/{bootstrap|material|fluent|indigo}.css.NET 9+ Web App projects can use the fingerprinted asset collection:
razor
<link rel="stylesheet" href="@Assets["_content/IgniteUI.Blazor/themes/light/bootstrap.css"]" />IgniteUI.Blazor.GridLitehtml
<link href="_content/IgniteUI.Blazor.GridLite/css/themes/light/bootstrap.css" rel="stylesheet" />宿主页面为 (WASM/MAUI)、(Server)或 (Web App)。
wwwroot/index.htmlPages/_Host.cshtmlComponents/App.razorIgniteUI.Blazor.Litehtml
<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />样式表是必需的:缺少它的话组件会无样式渲染。
主题文件路径 下的文件格式为 —— 请仅链接其中一个。
_content/IgniteUI.Blazor/themes/{light|dark}/{bootstrap|material|fluent|indigo}.css.NET 9 及以上版本的 Web App 项目可以使用带指纹的资产集合:
razor
<link rel="stylesheet" href="@Assets["_content/IgniteUI.Blazor/themes/light/bootstrap.css"]" />IgniteUI.Blazor.GridLitehtml
<link href="_content/IgniteUI.Blazor.GridLite/css/themes/light/bootstrap.css" rel="stylesheet" />5. Render mode (Blazor Web App only)
5. 渲染模式(仅 Blazor Web App 适用)
Ignite UI components need an interactive render mode; static SSR renders nothing usable.
razor
@rendermode InteractiveServerOr globally in : .
App.razor<Routes @rendermode="InteractiveServer" />Use or in place of as needed.
InteractiveWebAssemblyInteractiveAutoInteractiveServerIgnite UI 组件需要交互渲染模式;静态 SSR 无法渲染出可用的内容。
razor
@rendermode InteractiveServer或者在 中全局配置:。
App.razor<Routes @rendermode="InteractiveServer" />可根据需要使用 或 替换 。
InteractiveWebAssemblyInteractiveAutoInteractiveServer