add cake part

rem
remrem 2 years ago
parent 466741d3a1
commit bfd897fb3e

@ -0,0 +1,7 @@
@typeparam TItem
<h3>Card</h3>
<div class="card text-center">
@CardHeader(Item)
@CardBody(Item)
@CardFooter
</div>

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
public partial class Card<TItem>
{
[Parameter]
public RenderFragment<TItem> CardBody { get; set; }
[Parameter]
public RenderFragment CardFooter { get; set; }
[Parameter]
public RenderFragment<TItem> CardHeader { get; set; }
[Parameter]
public TItem Item { get; set; }
}
}

@ -0,0 +1,11 @@
@typeparam TItem
<div>
@if ((Items?.Count ?? 0) != 0)
{
@foreach (var item in Items)
{
@ShowTemplate(item);
}
}
</div>

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
public partial class ShowItems<TItem>
{
[Parameter]
public List<TItem> Items { get; set; }
[Parameter]
public RenderFragment<TItem> ShowTemplate { get; set; }
}
}

@ -0,0 +1,9 @@
namespace Blazor.Models
{
public class Cake
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Cost { get; set; }
}
}

@ -1,5 +1,7 @@
@page "/" @page "/"
@using System.Globalization @using System.Globalization
@using Blazor.Components
<PageTitle>Index</PageTitle> <PageTitle>Index</PageTitle>
@ -12,3 +14,18 @@ Welcome to your new app.
<p> <p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture <b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p> </p>
<Card Item="CakeItem" Context="cakeContext">
<CardHeader>
<div class="card-header">
Cake Token Number - @cakeContext.Id
</div>
</CardHeader>
<CardBody>
<div class="card-body">
<div>@cakeContext.Name</div>
<div>$ @cakeContext.Cost</div>
</div>
</CardBody>
</Card>

@ -0,0 +1,14 @@
using Blazor.Models;
namespace Blazor.Pages
{
public partial class Index
{
private Cake CakeItem = new Cake
{
Id = 1,
Name = "Black Forest",
Cost = 50
};
}
}

@ -1,6 +1,6 @@
@page "/list" @page "/list"
@using Models @using Models
@* <h3>@Localizer["Title"]</h3> *@ <h3>@Localizer["Title"]</h3>
... ...

@ -6,6 +6,7 @@ using Blazored.Modal;
using Blazored.Modal.Services; using Blazored.Modal.Services;
using Blazorise.DataGrid; using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace Blazor.Pages namespace Blazor.Pages
{ {
@ -27,8 +28,8 @@ namespace Blazor.Pages
[CascadingParameter] [CascadingParameter]
public IModalService Modal { get; set; } public IModalService Modal { get; set; }
//[Inject] [Inject]
//public IStringLocalizer<List> Localizer { get; set; } public IStringLocalizer<List> Localizer { get; set; }
private async Task OnReadData(DataGridReadDataEventArgs<Item> e) private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
{ {

Loading…
Cancel
Save