Skip to content

Commit e51d628

Browse files
committed
Add root level cascading values sample
1 parent 56c78a1 commit e51d628

File tree

15 files changed

+128
-4
lines changed

15 files changed

+128
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Samples for ASP.NET Core 6.0 (485)
1+
# Samples for ASP.NET Core 6.0 (486)
22

3-
- Samples for ASP.NET Core **8.0 Preview 7** is available [here](/projects/.net8) (23).
3+
- Samples for ASP.NET Core **8.0 Preview 7** is available [here](/projects/.net8) (24).
44
- Samples for ASP.NET Core **7.0** is available [here](/projects/.net7) (45).
55
- Samples for ASP.NET Core **8.0 Preview 6** using EdgeDB.NET is [here](https://github.com/edgedb/edgedb-net).
66

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.defaultSolution": "ComponentTwentyThree.sln"
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Router AppAssembly="typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<h1>Page not found</h1>
7+
<p>Sorry, but there's nothing here!</p>
8+
</NotFound>
9+
</Router>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>true</ImplicitUsings>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.7.*" />
8+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-preview.7.*" />
9+
<Watch Include="**\*.cshtml" />
10+
<Watch Include="**\*.razor" />
11+
</ItemGroup>
12+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentTwentyThree", "ComponentTwentyThree.csproj", "{26B459F9-76ED-44D4-AA0F-65D28D8E7861}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{26B459F9-76ED-44D4-AA0F-65D28D8E7861}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{26B459F9-76ED-44D4-AA0F-65D28D8E7861}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{26B459F9-76ED-44D4-AA0F-65D28D8E7861}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{26B459F9-76ED-44D4-AA0F-65D28D8E7861}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {6FC14629-365F-45CC-A524-50A03305E39D}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/"
2+
3+
<h1>Cascading Values</h1>
4+
5+
<InnerComponentOne />
6+
7+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h2>Inner Component One</h2>
2+
3+
@Message.Message
4+
5+
<InnerComponentTwo />
6+
7+
@code {
8+
[CascadingParameter]
9+
protected MessageCascade Message { get; set; } = default!;
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
<h3>Inner Component Two</h3>
3+
4+
@Message.Message
5+
6+
@code {
7+
[CascadingParameter]
8+
protected MessageCascade Message { get; set; } = default!;
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
2+
using ComponentTwentyThree;
3+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
4+
builder.RootComponents.Add<App>("app");
5+
builder.Services.AddCascadingValue(sp => new MessageCascade("Hello World!"));
6+
7+
var app = builder.Build();
8+
await app.RunAsync();
9+
10+
public record MessageCascade(string Message);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Setting fixed root level cascading values
2+
3+
This sample shows how to set root level cascading values without using `<CascadingValue/>` component.

0 commit comments

Comments
 (0)