Templated Razor Components
Explore how to define and use templated Razor components in Blazor to build reusable UI sections. Understand setting up generic templates for tables with RenderFragment properties, passing data collections, and rendering dynamic content efficiently within component pages.
We'll cover the following...
We'll cover the following...
To make it easy to build reusable components, Blazor allows us to create component templates. This is what we will cover in this lesson. To demonstrate how the Razor component templates work, we have the following project setup:
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Templated Razor component example