You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/virtualization.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -274,6 +274,34 @@ The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> com
274
274
275
275
:::moniker-end
276
276
277
+
:::moniker range=">= aspnetcore-11.0"
278
+
279
+
## Control viewport scroll position behavior when items are dynamically added
280
+
281
+
<!-- UPDATE 11.0 - API cross-links -->
282
+
283
+
Assign a `VirtualizeAnchorMode` value to the `AnchorMode` parameter to control how the viewport behaves at list edges when items are dynamically added:
284
+
285
+
*`None`: No edge pinning. The viewport stays at current scroll position regardless of item changes.
286
+
*`Beginning`: Pins the viewport to the beginning of the list. When the user is at a scroll position near the top of the list and new items arrive at the beginning, the viewport stays at the top showing the newest items. For example, this pinning behavior is useful for a news feed user experience.
287
+
*`End`: Pins the viewport to the end of the list. When the user is at a scroll position near the bottom of the list and new items arrive at the end, the viewport auto-scrolls to show them. If the user has scrolled away, auto-scroll disengages until they return to the bottom. For example, this pinning behavior is useful for a chat or logging user experience.
288
+
289
+
The following example pins the viewport to the beginning of a virtualized flight list:
Modes can be combined. For example, assigning `Beginning | End` pins both edges. Combining `None` with other modes is supported but doesn't change the combined value.
300
+
301
+
`Virtualize.ItemComparer` gets or sets a comparer used to detect whether items were prepended or appended when using class-typed items with an <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.ItemsProvider%2A> (for more information, see the [Item provider delegate](#item-provider-delegate) section). The comparer determines if the first loaded item changed between provider calls, which indicates items were inserted at the top. For records, the default comparer's value-equality behavior (`EqualityComparer{T}.Default`) works automatically. For an in-memory <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.Items%2A> assignment, an `ItemComparer` comparer isn't required because the component can detect prepends automatically.
302
+
303
+
:::moniker-end
304
+
277
305
## State changes
278
306
279
307
When making changes to items rendered by the <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component, call <xref:Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged%2A> to enqueue re-evaluation and rerendering of the component. For more information, see <xref:blazor/components/rendering>.
Standalone Blazor WebAssembly: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
167
+
<!-- UPDATE 11.0 - Activate when the NuGet package is available.
Standalone Blazor WebAssembly: [`Microsoft.AspNetCore.Components.Gateway`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.Gateway): A lightweight ASP.NET Core host for serving standalone Blazor WebAssembly apps during development and production.
174
+
175
+
:::moniker-end
176
+
177
+
:::moniker range="< aspnetcore-11.0"
178
+
179
+
-->
180
+
181
+
Standalone Blazor WebAssembly: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor WebAssembly apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
182
+
183
+
<!-- UPDATE 11.0 - Activate when the NuGet package is available.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/state-management/server.md
+43-5Lines changed: 43 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,7 +213,7 @@ To persist temporary data between HTTP requests during static server-side render
213
213
`TempData`:
214
214
215
215
* Is available when <xref:Microsoft.Extensions.DependencyInjection.RazorComponentsServiceCollectionExtensions.AddRazorComponents%2A> is called in the app's `Program` file.
216
-
* Is provided as a cascading value with the [`[CascadingParameter]` attribute](xref:blazor/components/cascading-values-and-parameters#cascadingparameter-attribute).
216
+
* Is provided as a cascading value with the [`[CascadingParameter]` attribute](xref:blazor/components/cascading-values-and-parameters#cascadingparameter-attribute) or the `[SupplyParameterFromTempData]` parameter attribute.
* Stores `object?` values, requiring runtime casting (example: `var message = TempData["Message"] as string`). IntelliSense and type checking aren't supported.
@@ -224,6 +224,16 @@ To persist temporary data between HTTP requests during static server-side render
224
224
publicITempData?TempData { get; set; }
225
225
```
226
226
227
+
When supplied to a parameter for simple read/write of a single value, use the `[SupplyParameterFromTempData]` attribute without or with a key (string):
Similar to the preceding example but when only simple read/write of a single value is required, the following example uses the `[SupplyParameterFromTempData]` attribute.
*[Service defaults library for Blazor WebAssembly apps](#service-defaults-library-for-blazor-webassembly-apps): `blazor-wasm-servicedefaults`
502
+
503
+
> [!NOTE]
504
+
> The "Hosted" Blazor WebAssembly project template option isn't available in .NET 8 or later. To create a hosted Blazor WebAssembly app, a **Framework** option earlier than .NET 8 must be selected with the **ASP.NET Core Hosted** checkbox. However, we recommend a Blazor Web App for all new Blazor development in .NET 8 or later. For more information, see the following resources:
The Blazor framework provides project templates for creating new apps. The templates are used to create new Blazor projects and solutions regardless of the tooling that you select for Blazor development (Visual Studio, Visual Studio Code, or the [.NET command-line interface (CLI)](/dotnet/core/tools/)):
@@ -604,6 +620,32 @@ For more information on template options, see the following resources:
604
620
605
621
:::moniker-end
606
622
623
+
:::moniker range=">= aspnetcore-11.0"
624
+
625
+
## Service defaults library for Blazor WebAssembly apps
626
+
627
+
The `blazor-wasm-servicedefaults` project template creates a service default library for Blazor WebAssembly apps with .NET Aspire integration.
628
+
629
+
The template features:
630
+
631
+
*[OpenTelemetry](https://github.com/open-telemetry/opentelemetry-dotnet) support: Logging, metrics, and tracing with standard OTLP exporter.
632
+
* Service discovery integration via the [`Microsoft.Extensions.ServiceDiscovery` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.ServiceDiscovery).
633
+
* HTTP resilience using the standard resilience handler via the [`Microsoft.Extensions.Http.Resilience` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Http.Resilience).
634
+
635
+
Example template usage with an output name of `BlazorSample.ServiceDefaults`:
636
+
637
+
```dotnetcli
638
+
dotnet new blazor-wasm-servicedefaults -o BlazorSample.ServiceDefaults
639
+
```
640
+
641
+
Reference the library from the Blazor WebAssembly client and make the following call in the app's `Program` file:
Copy file name to clipboardExpand all lines: aspnetcore/release-notes/aspnetcore-11/includes/blazor.md
+42-4Lines changed: 42 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,14 +112,52 @@ TempData is available when <xref:Microsoft.Extensions.DependencyInjection.RazorC
112
112
publicITempData?TempData { get; set; }
113
113
```
114
114
115
-
For more information, see <xref:blazor/state-management/server?view=aspnetcore-11.0#server-side-storage>.
115
+
When supplied to a parameter for simple read/write of a single value, use the `[SupplyParameterFromTempData]` attribute:
116
+
117
+
```csharp
118
+
[SupplyParameterFromTempData]
119
+
publicstring?Message { get; set; }
120
+
```
121
+
122
+
For more information, see <xref:blazor/state-management/server?view=aspnetcore-11.0#temporary-data-persistence>.
116
123
117
124
### New Blazor Web Worker template (`blazorwebworker`)
118
125
119
126
Blazor WebAssembly apps can perform heavy computing on the client, but doing so on the UI thread interferes with UI rendering and negatively affects the user experience. In .NET 10, we added an article with a sample app to make offloading heavy work from the UI thread to a Web Worker easier. For .NET 11, we've added the Blazor Web Worker project template (`blazorwebworker`), which provides infrastructure for running .NET code in a Web Worker in Blazor WebAssembly apps. For more information, see <xref:blazor/blazor-web-workers?view=aspnetcore-11.0>.
120
127
121
-
### `Virtualize` adapts to variable-height items at runtime
128
+
### Virtualization enhancements
129
+
130
+
* The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component no longer assumes every item has the same height. The component now adapts to measured item sizes at runtime, which reduces incorrect spacing and scrolling when item heights vary. These updates include an update to the default value of <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.OverscanCount%2A?displayProperty=nameWithType>, which was `3` in .NET 10 or earlier and now changes to `15` in .NET 11 or later. The change in default value increases the precision of average item height calculations.
131
+
132
+
For more information, see the *Item size* and *Overscan count* sections of <xref:blazor/components/virtualization?view=aspnetcore-11.0#item-size>.
133
+
134
+
* Use the new `AnchorMode` parameter to control how the viewport behaves at list edges when items are dynamically added:
135
+
136
+
*`None`: No edge pinning. The viewport stays at current scroll position regardless of item changes.
137
+
*`Beginning`: Pins the viewport to the beginning of the list. For example, this pinning behavior is useful for a news feed user experience.
138
+
*`End`: Pins the viewport to the end of the list. For example, this pinning behavior is useful for a chat or logging user experience.
139
+
140
+
In the following example, the virtualized content is pinned to the beginning of the list:
141
+
142
+
```razor
143
+
<Virtualize AnchorMode="Beginning" ...>
144
+
...
145
+
</Virtualize>
146
+
```
147
+
148
+
For more information, see <xref:blazor/components/virtualization?view=aspnetcore-11.0#control-viewport-scroll-position-behavior-when-items-are-dynamically-added>.
149
+
150
+
### New service defaults library project template for Blazor WebAssembly apps
151
+
152
+
The `blazor-wasm-servicedefaults` project template creates a service default library for Blazor WebAssembly apps with .NET Aspire integration. For more information, see <xref:blazor/tooling?view=aspnetcore-11.0#service-defaults-library-for-blazor-webassembly-apps>.
153
+
154
+
### New development server for Blazor WebAssembly apps
The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component no longer assumes every item has the same height. The component now adapts to measured item sizes at runtime, which reduces incorrect spacing and scrolling when item heights vary. These updates include an update to the default value of <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.OverscanCount%2A?displayProperty=nameWithType>, which was `3` in .NET 10 or earlier and now changes to `15` in .NET 11 or later. The change in default value increases the precision of average item height calculations.
161
+
`Microsoft.AspNetCore.Components.Gateway` is a lightweight ASP.NET Core host that replaces [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer) for serving standalone Blazor WebAssembly applications during development and production.
124
162
125
-
For more information, see the *Item size* and *Overscan count* sections of <xref:blazor/components/virtualization?view=aspnetcore-11.0#item-size>.
163
+
For more information, see [[Blazor] Replace DevServer with BlazorGateway for standalone WASM apps (`dotnet/aspnetcore`#65982)](https://github.com/dotnet/aspnetcore/pull/65982).
0 commit comments