@@ -100,7 +100,11 @@ public partial class AutoComplete
100100 [ NotNull ]
101101 private IStringLocalizer < AutoComplete > ? Localizer { get ; set ; }
102102
103- private List < string > _items = [ ] ;
103+ /// <summary>
104+ /// 获得/设置 UI 呈现数据集合
105+ /// </summary>
106+ [ NotNull ]
107+ protected List < string > ? FilterItems { get ; set ; }
104108
105109 /// <summary>
106110 /// 获得 是否跳过 ESC 按键字符串
@@ -139,13 +143,13 @@ protected override void OnParametersSet()
139143 Icon ??= IconTheme . GetIconByKey ( ComponentIcons . AutoCompleteIcon ) ;
140144 LoadingIcon ??= IconTheme . GetIconByKey ( ComponentIcons . LoadingIcon ) ;
141145
142- _items = Items ? . ToList ( ) ?? [ ] ;
146+ FilterItems = Items ? . ToList ( ) ?? [ ] ;
143147 }
144148
145149 /// <summary>
146150 /// 鼠标点击候选项时回调此方法
147151 /// </summary>
148- protected virtual async Task OnClickItem ( string val )
152+ protected async Task OnClickItem ( string val )
149153 {
150154 CurrentValue = val ;
151155 if ( OnSelectedItemChanged != null )
@@ -164,20 +168,20 @@ public async Task TriggerOnChange(string val)
164168 if ( OnCustomFilter != null )
165169 {
166170 var items = await OnCustomFilter ( val ) ;
167- _items = items . ToList ( ) ;
171+ FilterItems = items . ToList ( ) ;
168172 }
169173 else
170174 {
171175 var comparison = IgnoreCase ? StringComparison . OrdinalIgnoreCase : StringComparison . Ordinal ;
172176 var items = IsLikeMatch
173177 ? Items . Where ( s => s . Contains ( val , comparison ) )
174178 : Items . Where ( s => s . StartsWith ( val , comparison ) ) ;
175- _items = items . ToList ( ) ;
179+ FilterItems = items . ToList ( ) ;
176180 }
177181
178182 if ( DisplayCount != null )
179183 {
180- _items = _items . Take ( DisplayCount . Value ) . ToList ( ) ;
184+ FilterItems = FilterItems . Take ( DisplayCount . Value ) . ToList ( ) ;
181185 }
182186
183187 CurrentValue = val ;
0 commit comments