parent
217347ea60
commit
446e5dda13
@ -0,0 +1,14 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public MyRootComponent RootComponent { get; set; }
|
||||
}
|
||||
|
||||
<div style="border: 1px solid black; padding: 10px;">
|
||||
<strong>MyFirstChildComponent - @RootComponent.Text</strong>
|
||||
<div>
|
||||
@ChildContent
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,16 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
<div style="border: 1px solid black; padding: 10px;">
|
||||
<strong>MyRootComponent - @Text</strong>
|
||||
<div>
|
||||
<CascadingValue Value="@this">
|
||||
@ChildContent
|
||||
</CascadingValue>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,14 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public MyRootComponent RootComponent { get; set; }
|
||||
}
|
||||
|
||||
<div style="border: 1px solid black; padding: 10px;">
|
||||
<strong>MySecondChildComponent - @RootComponent.Text</strong>
|
||||
<div>
|
||||
@ChildContent
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,35 @@
|
||||
@page "/call-js-example-1"
|
||||
@inject IJSRuntime JS
|
||||
|
||||
<h1>Call JS <code>convertArray</code> Function</h1>
|
||||
|
||||
<p>
|
||||
<button @onclick="ConvertArray">Convert Array</button>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@text
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://www.imdb.com/title/tt0379786/" target="_blank">Serenity</a><br>
|
||||
<a href="https://www.imdb.com/name/nm0472710/" target="_blank">David Krumholtz on IMDB</a>
|
||||
</p>
|
||||
|
||||
@code {
|
||||
private MarkupString text;
|
||||
|
||||
private uint[] quoteArray =
|
||||
new uint[]
|
||||
{
|
||||
60, 101, 109, 62, 67, 97, 110, 39, 116, 32, 115, 116, 111, 112, 32,
|
||||
116, 104, 101, 32, 115, 105, 103, 110, 97, 108, 44, 32, 77, 97,
|
||||
108, 46, 60, 47, 101, 109, 62, 32, 45, 32, 77, 114, 46, 32, 85, 110,
|
||||
105, 118, 101, 114, 115, 101, 10, 10,
|
||||
};
|
||||
|
||||
private async Task ConvertArray()
|
||||
{
|
||||
text = new(await JS.InvokeAsync<string>("convertArray", quoteArray));
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
@page "/call-js-example-3"
|
||||
@inject IJSRuntime JS
|
||||
|
||||
<h1>Call JS Example 3</h1>
|
||||
|
||||
<p>
|
||||
<button @onclick="SetStock">Set Stock</button>
|
||||
</p>
|
||||
|
||||
@if (stockSymbol is not null)
|
||||
{
|
||||
<p>@stockSymbol price: @price.ToString("c")</p>
|
||||
}
|
||||
|
||||
@if (result is not null)
|
||||
{
|
||||
<p>@result</p>
|
||||
}
|
||||
|
||||
@code {
|
||||
private Random r = new();
|
||||
private string? stockSymbol;
|
||||
private decimal price;
|
||||
private string? result;
|
||||
|
||||
private async Task SetStock()
|
||||
{
|
||||
stockSymbol =
|
||||
$"{(char)('A' + r.Next(0, 26))}{(char)('A' + r.Next(0, 26))}";
|
||||
price = r.Next(1, 101);
|
||||
var interopResult =
|
||||
await JS.InvokeAsync<string>("displayTickerAlert2", stockSymbol, price);
|
||||
result = $"Result of TickerChanged call for {stockSymbol} at " +
|
||||
$"{price.ToString("c")}: {interopResult}";
|
||||
}
|
||||
}
|
Loading…
Reference in new issue