![]() |
|
Blazor 0.6.0 experimental release now available - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic & .NET (https://sickgaming.net/forum-79.html) +--- Thread: Blazor 0.6.0 experimental release now available (/thread-86706.html) |
Blazor 0.6.0 experimental release now available - xSicKxBot - 10-03-2018 Blazor 0.6.0 experimental release now available Blazor 0.6.0 is now available! This release includes new features for authoring templated components and enables using server-side Blazor with the Azure SignalR Service. We’re also excited to announce our plans to ship the server-side Blazor model as Razor Components in .NET Core 3.0! Here’s what’s new in the Blazor 0.6.0 release:
A full list of the changes in this release can be found in the Blazor 0.6.0 release notes. Get Blazor 0.6.0 Install the following:
You can find getting started instructions, docs, and tutorials for Blazor at https://blazor.net. Upgrade an existing project to Blazor 0.6.0 To upgrade a Blazor 0.5.x project to 0.6.0:
That’s it! You’re now ready to try out the latest Blazor features. Templated components Blazor 0.6.0 adds support for templated components. Templated components are components that accept one or more UI templates as parameters, which can then be used as part of the component’s rendering logic. Templated components allow you to author higher-level components that are more reusable than what was possible before. For example, a list view component could allow the user to specify a template for rending items in the list, or a grid component could allow the user to specify templates for the grid header and for each row. Template parameters A templated component is defined by specifying one or more component parameters of type Code: RenderFragmentCode: RenderFragment<T>TemplatedTable.cshtml Code: @typeparam TItem
<table> <thead> <tr>@TableHeader</tr> </thead> <tbody> @foreach (var item in Items) { @RowTemplate(item) } </tbody> <tfoot> <tr>@TableFooter</tr> </tfoot>
</table>
@functions { [Parameter] RenderFragment TableHeader { get; set; } [Parameter] RenderFragment<TItem> RowTemplate { get; set; } [Parameter] RenderFragment TableFooter { get; set; } [Parameter] IReadOnlyList<TItem> Items { get; set; }
}When using a templated component, the template parameters can be specified using child elements that match the names of the parameters. Code: <TemplatedTable Items="@pets"> <TableHeader> <th>ID</th> <th>Name</th> <th>Species</th> </TableHeader> <RowTemplate> <td>@context.PetId</td> <td>@context.Name</td> <td>@context.Species</td> </RowTemplate>
</TemplatedTable>Component arguments of type Code: RenderFragment<T>Code: contextCode: ContextCode: <TemplatedTable Items="@pets"> <TableHeader> <th>ID</th> <th>Name</th> <th>Species</th> </TableHeader> <RowTemplate Context="pet"> <td>@pet.PetId</td> <td>@pet.Name</td> <td>@pet.Species</td> </RowTemplate>
</TemplatedTable>Alternatively, you can specify the Code: ContextCode: <TemplatedTable Context="pet">Code: ContextGeneric-typed components Templated components are often generically typed. For example, a generic Code: ListViewCode: IEnumerable<T>Code: @typeparamGenericComponent.cshtml Code: @typeparam TItem
@foreach (var item in Items)
{ @ItemTemplate(item)
}
@functions { [Parameter] RenderFragment<TItem> ItemTemplate { get; set; } [Parameter] IReadOnlyList<TItem> Items { get; set; }
}When using generic-typed components the type parameter will be inferred if possible. Otherwise, it must be explicitly specified using an attribute that matches the name of the type parameter: Code: <GenericComponent Items="@pets" TItem="Pet"> ...
</GenericComponent>Render fragments can be defined using Razor template syntax. Razor templates are a way to define a UI snippet. They look like the following: Code: @<tag>...<tag>You can now use Razor templates to define Code: RenderFragmentCode: RenderFragment<T>Code: @{ RenderFragment template = @<p>The time is @DateTime.Now.</p>; RenderFragment<Pet> petTemplate = (pet) => @<p>Your pet's name is @pet.Name.</p>
}Render fragments defined using Razor templates can be passed as arguments to templated components or rendered directly. For example, you can render the previous templates directly like this: Code: @template
@petTemplate(new Pet { Name = "Fido" })In the previous Blazor release we added support for running Blazor on the server where UI interactions and DOM updates are handled over a SignalR connection. In this release we refactored the server-side Blazor support to enable using server-side Blazor with the Azure SignalR Service. The Azure SignalR Service handles connection scale out for SignalR based apps, scaling up to handle thousands of persistent connections so that you don’t have to. To use the Azure SignalR Service with a server-side Blazor application:
Razor Components to ship with ASP.NET Core in .NET Core 3.0 We announced last month at .NET Conf that we’ve decided to move forward with shipping the Blazor server-side model as part of ASP.NET Core in .NET Core 3.0. About half of Blazor users have indicated they would use the Blazor server-side model, and shipping it in .NET Core 3.0 will make it available for production use. As part of integrating the Blazor component model into the ASP.NET Core we’ve decided to give it a new name to differentiate it from the ability to run .NET in the browser: Razor Components. We are now working towards shipping Razor Components and the editing in .NET Core 3.0. This includes integrating Razor Components into ASP.NET Core so that it can be used from MVC. We expect to have a preview of this support early next year after the ASP.NET Core 2.2 release has wrapped up. Our primary goal remains to ship support for running Blazor client-side in the browser. Work on running Blazor client-side on WebAssembly will continue in parallel with the Razor Components work, although it will remain experimental for a while longer while we work through the issues of running .NET on WebAssembly. We will however keep the component model the same regardless of whether you are running on the server or the client. You can switch your Blazor app to run on the client or the server by changing a single line of code. See the Blazor .NET Conf talk to see this in action and to learn more about our plans for Razor Components: Give feedback We hope you enjoy this latest preview release of Blazor. As with previous releases, your feedback is important to us. If you run into issues or have questions while trying out Blazor, file issues on GitHub. You can also chat with us and the Blazor community on Gitter if you get stuck or to share how Blazor is working for you. After you’ve tried out Blazor for a while please let us know what you think by taking our in-product survey. Click the survey link shown on the app home page when running one of the Blazor project templates: Thanks for trying out Blazor! |