Skip to content

Commit ea58aba

Browse files
committed
doc: 增加 ItemTemplate 示例
1 parent 8eaf16c commit ea58aba

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
</div>
3232
</DemoBlock>
3333

34+
<DemoBlock Title="@Localizer["DropdownItemTemplateTitle"]" Introduction="@Localizer["DropdownItemTemplateIntro"]" Name="ItemTemplate">
35+
<Dropdown TValue="string" Items="ItemTemplateList">
36+
<ItemTemplate>
37+
<Tooltip Title="just a tooltip text demo" Trigger="hover">
38+
<span class="fa-solid fa-flag"></span>
39+
<div class="ms-2 flex-fill">@context.Text</div>
40+
</Tooltip>
41+
</ItemTemplate>
42+
</Dropdown>
43+
</DemoBlock>
44+
3445
<DemoBlock Title="@Localizer["SplitTitle"]" Introduction='@Localizer["SplitIntro"]' Name="Split">
3546
<div class="row g-3">
3647
<div class="col-6 col-sm-4 col-md-3">

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public sealed partial class Dropdowns
1818

1919
private List<SelectedItem> Items { get; set; } = [];
2020

21+
private List<SelectedItem> ItemTemplateList { get; set; } = [];
22+
2123
/// <summary>
2224
/// ShowMessage
2325
/// </summary>
@@ -41,6 +43,13 @@ protected override void OnInitialized()
4143
new SelectedItem() { Text=Localizer["Item3"], Value="2"},
4244
];
4345

46+
ItemTemplateList =
47+
[
48+
new SelectedItem() { Text=Localizer["Item1"], Value="0"},
49+
new SelectedItem() { Text=Localizer["Item2"], Value="1"},
50+
new SelectedItem() { Text=Localizer["Item3"], Value="2"},
51+
];
52+
4453
Foos =
4554
[
4655
new SelectedItem{ Text=Localizer["Item1"], Value="0"},

0 commit comments

Comments
 (0)