Skip to content

Commit 656b668

Browse files
authored
Merge branch 'lukekaese-pr-update-wpickett' into main
2 parents 597e944 + e5b3610 commit 656b668

File tree

79 files changed

+6259
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+6259
-278
lines changed

.openpublishing.publish.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"branch_mapping": {}
4848
},
4949
{
50-
"path_to_root": "xamarin-forms-samples",
51-
"url": "https://github.com/xamarin/xamarin-forms-samples",
50+
"path_to_root": "maui-samples",
51+
"url": "https://github.com/dotnet/maui-samples",
5252
"branch": "main",
5353
"branch_mapping": {}
5454
},
@@ -93,4 +93,4 @@
9393
"docs_build_engine": {
9494
"name": "docfx_v3"
9595
}
96-
}
96+
}

aspnetcore/blazor/components/cascading-values-and-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public interface ITab
394394
395395
The following `TabSet` component maintains a set of tabs. The tab set's `Tab` components, which are created later in this section, supply the list items (`<li>...</li>`) for the list (`<ul>...</ul>`).
396396

397-
Child `Tab` components aren't explicitly passed as parameters to the `TabSet`. Instead, the child `Tab` components are part of the child content of the `TabSet`. However, the `TabSet` still needs a reference each `Tab` component so that it can render the headers and the active tab. To enable this coordination without requiring additional code, the `TabSet` component *can provide itself as a cascading value* that is then picked up by the descendent `Tab` components.
397+
Child `Tab` components aren't explicitly passed as parameters to the `TabSet`. Instead, the child `Tab` components are part of the child content of the `TabSet`. However, the `TabSet` still needs a reference to each `Tab` component so that it can render the headers and the active tab. To enable this coordination without requiring additional code, the `TabSet` component *can provide itself as a cascading value* that is then picked up by the descendent `Tab` components.
398398

399399
`TabSet.razor`:
400400

aspnetcore/blazor/security/includes/httpcontext.md renamed to aspnetcore/blazor/components/httpcontext.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
---
2+
title: IHttpContextAccessor/HttpContext in ASP.NET Core Blazor apps
3+
author: guardrex
4+
description: Learn about IHttpContextAccessor and HttpContext in ASP.NET Core Blazor apps.
5+
monikerRange: '>= aspnetcore-3.1'
6+
ms.author: riande
7+
ms.custom: mvc
8+
ms.date: 01/30/2025
9+
uid: blazor/components/httpcontext
10+
---
11+
# `IHttpContextAccessor`/`HttpContext` in ASP.NET Core Blazor apps
12+
13+
[!INCLUDE[](~/includes/not-latest-version-without-not-supported-content.md)]
14+
115
:::moniker range=">= aspnetcore-8.0"
216

317
<xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> generally should be avoided with interactive rendering because a valid <xref:Microsoft.AspNetCore.Http.HttpContext> isn't always available.
@@ -11,7 +25,14 @@
1125
public HttpContext? HttpContext { get; set; }
1226
```
1327

14-
For scenarios where the <xref:Microsoft.AspNetCore.Http.HttpContext> is required in interactive components, we recommend flowing the data via persistent component state from the server. For more information, see <xref:blazor/security/additional-scenarios#pass-tokens-to-a-server-side-blazor-app>.
28+
During interactive rendering, an <xref:Microsoft.AspNetCore.Http.HttpContext> instance might not even exist. For scenarios where the <xref:Microsoft.AspNetCore.Http.HttpContext> is required in interactive components, we recommend flowing context data with [persistent component state](xref:blazor/components/prerender#persist-prerendered-state) from the server.
29+
30+
For additional context in *advanced* edge cases&dagger;, see the discussion in the following articles:
31+
32+
* [HttpContext is valid in Interactive Server Rendering Blazor page (`dotnet/AspNetCore.Docs` #34301)](https://github.com/dotnet/AspNetCore.Docs/issues/34301)
33+
* [Security implications of using IHttpContextAccessor in Blazor Server (`dotnet/aspnetcore` #45699)](https://github.com/dotnet/aspnetcore/issues/45699)
34+
35+
&dagger;Most developers building and maintaining Blazor apps don't need to delve into advanced concepts as long as the general guidance in this article is followed.
1536

1637
:::moniker-end
1738

@@ -24,3 +45,5 @@ The recommended approach for passing request state to the Blazor app is through
2445
A critical aspect of server-side Blazor security is that the user attached to a given circuit might become updated at some point after the Blazor circuit is established but the <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> ***isn't updated***. For more information on addressing this situation with custom services, see <xref:blazor/security/additional-scenarios#circuit-handler-to-capture-users-for-custom-services>.
2546

2647
:::moniker-end
48+
49+
For guidance on <xref:Microsoft.AspNetCore.Http.IHttpContextAccessor> and <xref:Microsoft.AspNetCore.Http.HttpContext> in ASP.NET Core SignalR, see <xref:signalr/httpcontext>.

aspnetcore/blazor/components/index.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,10 +1865,6 @@ For more information, see the following resources:
18651865
* <xref:mvc/views/tag-helpers/builtin-th/component-tag-helper>
18661866
* <xref:blazor/components/integration>
18671867

1868-
## `IHttpContextAccessor`/`HttpContext`
1869-
1870-
[!INCLUDE[](~/blazor/security/includes/httpcontext.md)]
1871-
18721868
<!--Reference links in article-->
18731869
[1]: <xref:mvc/views/razor#code>
18741870
[2]: <xref:mvc/views/razor#using>

aspnetcore/blazor/components/prerender.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Prerendering guidance is organized in the Blazor documentation by subject matter
166166
* [Stateful reconnection after prerendering](xref:blazor/components/lifecycle#stateful-reconnection-after-prerendering)
167167
* [Prerendering with JavaScript interop](xref:blazor/components/lifecycle#prerendering-with-javascript-interop): This section also appears in the two JS interop articles on calling JavaScript from .NET and calling .NET from JavaScript.
168168
* [Handle incomplete asynchronous actions at render](xref:blazor/components/lifecycle#handle-incomplete-asynchronous-actions-at-render): Guidance for delayed rendering due to long-running lifecycle tasks during prerendering on the server.
169-
* [QuickGrid component sample app](xref:blazor/components/quickgrid#sample-app): The [**QuickGrid for Blazor** sample app](https://aspnet.github.io/quickgridsamples/) is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
169+
* [`QuickGrid` component sample app](xref:blazor/components/quickgrid#sample-app): The [**QuickGrid for Blazor** sample app](https://aspnet.github.io/quickgridsamples/) is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
170170
* [Prerendering when integrating components into Razor Pages and MVC apps](xref:blazor/components/integration)
171171

172172
* Authentication and authorization

aspnetcore/blazor/components/quickgrid.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: ASP.NET Core Blazor QuickGrid component
2+
title: ASP.NET Core Blazor `QuickGrid` component
33
author: guardrex
44
description: The QuickGrid component is a Razor component for quickly and efficiently displaying data in tabular form.
55
monikerRange: '>= aspnetcore-8.0'
@@ -12,7 +12,7 @@ uid: blazor/components/quickgrid
1212

1313
[!INCLUDE[](~/includes/not-latest-version-without-not-supported-content.md)]
1414

15-
The [`QuickGrid`](xref:Microsoft.AspNetCore.Components.QuickGrid) component is a Razor component for quickly and efficiently displaying data in tabular form. `QuickGrid` provides a simple and convenient data grid component for common grid rendering scenarios and serves as a reference architecture and performance baseline for building data grid components. `QuickGrid` is highly optimized and uses advanced techniques to achieve optimal rendering performance.
15+
The [`QuickGrid` component](xref:Microsoft.AspNetCore.Components.QuickGrid) is a Razor component for quickly and efficiently displaying data in tabular form. QuickGrid provides a simple and convenient data grid component for common grid rendering scenarios and serves as a reference architecture and performance baseline for building data grid components. QuickGrid is highly optimized and uses advanced techniques to achieve optimal rendering performance.
1616

1717
## Package
1818

@@ -22,9 +22,9 @@ Add a package reference for the [`Microsoft.AspNetCore.Components.QuickGrid`](ht
2222

2323
## Sample app
2424

25-
For various `QuickGrid` demonstrations, see the [**QuickGrid for Blazor** sample app](https://aspnet.github.io/quickgridsamples/). The demo site is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
25+
For various QuickGrid demonstrations, see the [**QuickGrid for Blazor** sample app](https://aspnet.github.io/quickgridsamples/). The demo site is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
2626

27-
## `QuickGrid` implementation
27+
## QuickGrid implementation
2828

2929
To implement a `QuickGrid` component:
3030

@@ -41,7 +41,7 @@ To implement a `QuickGrid` component:
4141
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.ItemKey%2A>: Optionally defines a value for `@key` on each rendered row. Typically, this is used to specify a unique identifier, such as a primary key value, for each data item. This allows the grid to preserve the association between row elements and data items based on their unique identifiers, even when the `TGridItem` instances are replaced by new copies (for example, after a new query against the underlying data store). If not set, the `@key` is the `TGridItem` instance.
4242
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.OverscanCount%2A>: Defines how many additional items to render before and after the visible region to reduce rendering frequency during scrolling. While higher values can improve scroll smoothness by rendering more items off-screen, a higher value can also result in an increase in initial load times. Finding a balance based on your data set size and user experience requirements is recommended. The default value is 3. Only available when using <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.Virtualize%2A>.
4343
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.Pagination%2A>: Optionally links this `TGridItem` instance with a <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState> model, causing the grid to fetch and render only the current page of data. This is normally used in conjunction with a <xref:Microsoft.AspNetCore.Components.QuickGrid.Paginator> component or some other UI logic that displays and updates the supplied <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState> instance.
44-
* In the `QuickGrid` child content (<xref:Microsoft.AspNetCore.Components.RenderFragment>), specify <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2>s, which represent `TGridItem` columns whose cells display values:
44+
* In the QuickGrid child content (<xref:Microsoft.AspNetCore.Components.RenderFragment>), specify <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2>s, which represent `TGridItem` columns whose cells display values:
4545
* <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Property%2A>: Defines the value to be displayed in this column's cells.
4646
* <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Format%2A>: Optionally specifies a format string for the value. Using <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Format%2A> requires the `TProp` type to implement <xref:System.IFormattable>.
4747
* <xref:Microsoft.AspNetCore.Components.QuickGrid.ColumnBase%601.Sortable%2A>: Indicates whether the data should be sortable by this column. The default value may vary according to the column type. For example, a <xref:Microsoft.AspNetCore.Components.QuickGrid.TemplateColumn%601> is sorted if any <xref:Microsoft.AspNetCore.Components.QuickGrid.TemplateColumn%601.SortBy%2A> parameter is specified.
@@ -65,7 +65,7 @@ To implement a `QuickGrid` component:
6565
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.ItemSize%2A>: Only applicable when using <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.Virtualize%2A>. <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.ItemSize%2A> defines an expected height in pixels for each row, allowing the virtualization mechanism to fetch the correct number of items to match the display size and to ensure accurate scrolling.
6666
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.ItemKey%2A>: Optionally defines a value for `@key` on each rendered row. Typically, this is used to specify a unique identifier, such as a primary key value, for each data item. This allows the grid to preserve the association between row elements and data items based on their unique identifiers, even when the `TGridItem` instances are replaced by new copies (for example, after a new query against the underlying data store). If not set, the `@key` is the `TGridItem` instance.
6767
* <xref:Microsoft.AspNetCore.Components.QuickGrid.QuickGrid%601.Pagination%2A>: Optionally links this `TGridItem` instance with a <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState> model, causing the grid to fetch and render only the current page of data. This is normally used in conjunction with a <xref:Microsoft.AspNetCore.Components.QuickGrid.Paginator> component or some other UI logic that displays and updates the supplied <xref:Microsoft.AspNetCore.Components.QuickGrid.PaginationState> instance.
68-
* In the `QuickGrid` child content (<xref:Microsoft.AspNetCore.Components.RenderFragment>), specify <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2>s, which represent `TGridItem` columns whose cells display values:
68+
* In the QuickGrid child content (<xref:Microsoft.AspNetCore.Components.RenderFragment>), specify <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2>s, which represent `TGridItem` columns whose cells display values:
6969
* <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Property%2A>: Defines the value to be displayed in this column's cells.
7070
* <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Format%2A>: Optionally specifies a format string for the value. Using <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn%602.Format%2A> requires the `TProp` type to implement <xref:System.IFormattable>.
7171
* <xref:Microsoft.AspNetCore.Components.QuickGrid.ColumnBase%601.Sortable%2A>: Indicates whether the data should be sortable by this column. The default value may vary according to the column type. For example, a <xref:Microsoft.AspNetCore.Components.QuickGrid.TemplateColumn%601> is sorted if any <xref:Microsoft.AspNetCore.Components.QuickGrid.TemplateColumn%601.SortBy%2A> parameter is specified.
@@ -97,7 +97,7 @@ For Blazor Web Apps, the `QuickGrid` component must adopt an [interactive render
9797

9898
Access the component in a browser at the relative path `/promotion-grid`.
9999

100-
There aren't current plans to extend `QuickGrid` with features that full-blown commercial grids tend to offer, for example, hierarchical rows, drag-to-reorder columns, or Excel-like range selections. If you require advanced features that you don't wish to develop on your own, continue using third-party grids.
100+
There aren't current plans to extend QuickGrid with features that full-blown commercial grids tend to offer, for example, hierarchical rows, drag-to-reorder columns, or Excel-like range selections. If you require advanced features that you don't wish to develop on your own, continue using third-party grids.
101101

102102
## Sort by column
103103

@@ -109,7 +109,7 @@ Add `Sortable="true"` (<xref:Microsoft.AspNetCore.Components.QuickGrid.ColumnBas
109109
<PropertyColumn Property="..." Sortable="true" />
110110
```
111111

112-
In the running app, sort the `QuickGrid` column by selecting the rendered column title.
112+
In the running app, sort the QuickGrid column by selecting the rendered column title.
113113

114114
## Page items with a `Paginator` component
115115

@@ -191,6 +191,34 @@ QuickGrid also supports passing custom attributes and style classes (<xref:Micro
191191
<QuickGrid Items="..." custom-attribute="value" Class="custom-class">
192192
```
193193

194+
:::moniker range=">= aspnetcore-10.0"
195+
196+
## Style a table row based on the row item
197+
198+
<!-- UPDATE 10.0 API cross-link -->
199+
200+
Apply a stylesheet class to a row of the grid based on the row item using the `RowClass` parameter.
201+
202+
In the following example:
203+
204+
* A row item is represented by the `Person` [record](/dotnet/csharp/language-reference/builtin-types/record). The `Person` record includes a `FirstName` property.
205+
* The `HighlightJulie` method applies the `highlight` class styles to any row where the person's first name is "`Julie`."
206+
207+
```razor
208+
<QuickGrid ... RowClass="HighlightJulie">
209+
...
210+
</QuickGrid>
211+
212+
@code {
213+
private record Person(int PersonId, string FirstName, string LastName);
214+
215+
private string HighlightJulie(Person person) =>
216+
person.FirstName == "Julie" ? "highlight" : null;
217+
}
218+
```
219+
220+
:::moniker-end
221+
194222
## Entity Framework Core (EF Core) data source
195223

196224
Use the factory pattern to resolve an EF Core database context that provides data to a `QuickGrid` component. For more information on why the factory pattern is recommended, see <xref:blazor/blazor-ef-core>.
@@ -400,9 +428,9 @@ The <xref:Microsoft.AspNetCore.Components.QuickGrid.GridItemsProvider%601> conve
400428

401429
For more information on calling web APIs, see <xref:blazor/call-web-api>.
402430

403-
## `QuickGrid` scaffolder
431+
## QuickGrid scaffolder
404432

405-
The `QuickGrid` scaffolder scaffolds Razor components with `QuickGrid` to display data from a database.
433+
The QuickGrid scaffolder scaffolds Razor components with QuickGrid to display data from a database.
406434

407435
The scaffolder generates basic Create, Read, Update, and Delete (CRUD) pages based on an Entity Framework Core data model. You can scaffold individual pages or all of the CRUD pages. You select the model class and the `DbContext`, optionally creating a new `DbContext` if needed.
408436

@@ -538,4 +566,4 @@ dotnet aspnet-codegenerator blazor -h
538566

539567
---
540568

541-
For an example use of the `QuickGrid` scaffolder, see <xref:blazor/tutorials/movie-database-app/index>.
569+
For an example use of the QuickGrid scaffolder, see <xref:blazor/tutorials/movie-database-app/index>.

0 commit comments

Comments
 (0)