Skip to content

Commit dd24781

Browse files
committed
doc: 增加示例
1 parent c299e1d commit dd24781

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/BootstrapBlazor.Server/Components/Samples/Radios.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@
125125
</ValidateForm>
126126
</DemoBlock>
127127

128+
<DemoBlock Title="@Localizer["GenericTitle"]" Introduction="@Localizer["GenericIntro"]" Name="Generic">
129+
<RadioListGeneric @bind-Value="@_selectedFoo" Items="@GenericItems" />
130+
<section ignore>
131+
<div>@_selectedFoo.Name</div>
132+
</section>
133+
</DemoBlock>
134+
128135
<AttributeTable Items="@GetAttributes()" />
129136

130137
<EventTable Items="@GetEvents()" />

src/BootstrapBlazor.Server/Components/Samples/Radios.razor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using DocumentFormat.OpenXml.Office2010.Excel;
7+
using DocumentFormat.OpenXml.Wordprocessing;
8+
69
namespace BootstrapBlazor.Server.Components.Samples;
710

811
/// <summary>
@@ -52,6 +55,12 @@ private Task OnSelectedChanged(IEnumerable<SelectedItem> values, string val)
5255
return Task.CompletedTask;
5356
}
5457

58+
[NotNull]
59+
private IEnumerable<SelectedItem<Foo>>? GenericItems { get; set; }
60+
61+
[NotNull]
62+
private Foo? _selectedFoo = default;
63+
5564
/// <summary>
5665
/// OnInitialized 方法
5766
/// </summary>
@@ -85,6 +94,15 @@ protected override void OnInitialized()
8594

8695
Model = Foo.Generate(LocalizerFoo);
8796
FooItems = Foo.GetCompleteItems(LocalizerFoo);
97+
98+
GenericItems = new List<SelectedItem<Foo>>()
99+
{
100+
new() { Text = Localizer["item1"], Value = new Foo() { Id = 1, Name = LocalizerFoo["Foo.Name", "001"] } },
101+
new() { Text = Localizer["item2"], Value = new Foo() { Id = 2, Name = LocalizerFoo["Foo.Name", "002"] } },
102+
new() { Text = Localizer["item3"], Value = new Foo() { Id = 3, Name = LocalizerFoo["Foo.Name", "003"] } },
103+
};
104+
105+
_selectedFoo = new Foo() { Id = 1, Name = LocalizerFoo["Foo.Name", "001"] };
88106
}
89107

90108
private Task OnItemChanged(IEnumerable<SelectedItem> values, SelectedItem val)

0 commit comments

Comments
 (0)