Skip to content

Commit c44b0d7

Browse files
authored
add item click event callback for notice list (#30)
1 parent 8dbd024 commit c44b0d7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/layout/src/NoticeIcon/NoticeList.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Class="list"
1717
DataSource="@Data"
1818
ItemLayout="ListItemLayout.Horizontal">
19-
<ListItem>
19+
<ListItem OnClick="@(()=> HandleItemClick(context.Key))">
2020
<!--todo: Description shoud be RenderFragment-->
2121
@if (string.IsNullOrEmpty(context.Avatar))
2222
{

src/layout/src/NoticeIcon/NoticeList.razor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public partial class NoticeList
1515
[Parameter] public bool ShowViewMore { get; set; }
1616
[Parameter] public EventCallback OnClear { get; set; }
1717
[Parameter] public EventCallback OnViewMore { get; set; }
18+
[Parameter] public EventCallback<string> OnItemClick { get; set; }
19+
1820
[Parameter] public string Title { get; set; }
1921

2022
[CascadingParameter] public NoticeIcon NoticeIcon { get; set; }
@@ -48,5 +50,13 @@ public async Task HandleViewMore()
4850

4951
if (NoticeIcon.OnViewMore.HasDelegate) await NoticeIcon.OnViewMore.InvokeAsync(TabKey);
5052
}
53+
54+
public async Task HandleItemClick(string key)
55+
{
56+
if (OnItemClick.HasDelegate)
57+
{
58+
await OnItemClick.InvokeAsync(key);
59+
}
60+
}
5161
}
5262
}

0 commit comments

Comments
 (0)