File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
src/BootstrapBlazor/Components/ListGroup Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1414 <div class =" list-group-body scroll" >
1515 @foreach ( var item in Items )
1616 {
17- <div @key =" item" class =" @GetItemClassString(item)" @onclick =" () => OnClick(item)" >
17+ <div @key =" item" class =" @GetItemClassString(item)"
18+ @onclick =" () => OnClick(item)" @ondblclick =" () => OnDoubleClick(item)" >
1819 @if (ItemTemplate != null )
1920 {
2021 @ItemTemplate(item)
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ public partial class ListGroup<TItem>
4444 [ Parameter ]
4545 public Func < TItem , Task > ? OnClickItem { get ; set ; }
4646
47+ /// <summary>
48+ /// 获得/设置 双击 List 项目回调方法
49+ /// </summary>
50+ [ Parameter ]
51+ public Func < TItem , Task > ? OnDoubleClickItem { get ; set ; }
52+
4753 /// <summary>
4854 /// 获得/设置 获得条目显示文本内容回调方法
4955 /// </summary>
@@ -55,7 +61,7 @@ public partial class ListGroup<TItem>
5561 . Build ( ) ;
5662
5763 private string ? GetItemClassString ( TItem item ) => CssBuilder . Default ( "list-group-item" )
58- . AddClass ( "active" , Value != null && Value . Equals ( item ) )
64+ . AddClass ( "active" , Value . Equals ( item ) )
5965 . Build ( ) ;
6066
6167 /// <summary>
@@ -78,4 +84,13 @@ private async Task OnClick(TItem item)
7884 }
7985 CurrentValue = item ;
8086 }
87+
88+ private async Task OnDoubleClick ( TItem item )
89+ {
90+ if ( OnDoubleClickItem != null )
91+ {
92+ await OnDoubleClickItem ( item ) ;
93+ }
94+ CurrentValue = item ;
95+ }
8196}
You can’t perform that action at this time.
0 commit comments