diff --git a/aspnetcore/blazor/components/cascading-values-and-parameters.md b/aspnetcore/blazor/components/cascading-values-and-parameters.md index 09a8e69d20ef..68c0a96128fa 100644 --- a/aspnetcore/blazor/components/cascading-values-and-parameters.md +++ b/aspnetcore/blazor/components/cascading-values-and-parameters.md @@ -241,7 +241,7 @@ The following component is used to demonstrate how changing the value of `Notify private int dalekCount; [CascadingParameter] - public NotifyingDalek? Dalek { get; set; } + private NotifyingDalek? Dalek { get; set; } private void Update() { @@ -433,6 +433,8 @@ For more information, see the following sections of this article: To make use of cascading values, descendent components declare cascading parameters using the [`[CascadingParameter]` attribute](xref:Microsoft.AspNetCore.Components.CascadingParameterAttribute). Cascading values are bound to cascading parameters **by type**. Cascading multiple values of the same type is covered in the [Cascade multiple values](#cascade-multiple-values) section later in this article. +The `private` access modifier is recommended for cascading parameters because the parameter should be scoped for use only within the component's class in most cases. When subclassing is required, use the `protected` access modifier. + The following component binds the `ThemeInfo` cascading value to a cascading parameter, optionally using the same name of `ThemeInfo`. The parameter is used to set the CSS class for the **`Increment Counter (Themed)`** button. `ThemedCounter.razor`: @@ -657,7 +659,7 @@ Descendent `Tab` components capture the containing `TabSet` as a cascading param @code { [CascadingParameter] - public TabSet? ContainerTabSet { get; set; } + private TabSet? ContainerTabSet { get; set; } [Parameter] public string? Title { get; set; } diff --git a/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md b/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md index e5699f5be141..655ac45d200b 100644 --- a/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md +++ b/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md @@ -125,7 +125,7 @@ Reusable components are free to receive an