1- using System ;
1+ using Syncfusion . Windows . Controls . Input ;
2+ using Syncfusion . Windows . Utils ;
3+ using System ;
24using System . Collections . Generic ;
35using System . Collections . ObjectModel ;
46using System . Linq ;
57using System . Text ;
68using System . Threading . Tasks ;
9+ using System . Windows . Input ;
710
811namespace Multipath_Search
912{
1013 public class ViewModel
1114 {
15+ public ICommand AutoCompleteLoaded
16+ {
17+ get ;
18+ private set ;
19+ }
20+
1221 private ObservableCollection < Model > employeeCollection ;
1322 public ObservableCollection < Model > EmployeeCollection
1423 {
@@ -17,6 +26,7 @@ public ObservableCollection<Model> EmployeeCollection
1726 }
1827 public ViewModel ( )
1928 {
29+ AutoCompleteLoaded = new DelegateCommand ( AutoCompleteLoadedMethod ) ;
2030 employeeCollection = new ObservableCollection < Model > ( ) ;
2131 employeeCollection . Add ( new Model ( ) { ID = 1 , Name = "Eric" } ) ;
2232 employeeCollection . Add ( new Model ( ) { ID = 2 , Name = "James" } ) ;
@@ -28,5 +38,25 @@ public ViewModel()
2838 employeeCollection . Add ( new Model ( ) { ID = 8 , Name = "Alan" } ) ;
2939 employeeCollection . Add ( new Model ( ) { ID = 9 , Name = "Aaron" } ) ;
3040 }
41+ private void AutoCompleteLoadedMethod ( object obj )
42+ {
43+ var autocomplete = obj as SfTextBoxExt ;
44+ if ( autocomplete != null )
45+ {
46+ autocomplete . Filter = CustomFilter ;
47+ }
48+ }
49+ public bool CustomFilter ( string search , object item )
50+ {
51+ var model = item as Model ;
52+ if ( model != null )
53+ {
54+ if ( ( model . Name . ToLower ( ) . Contains ( search . ToLower ( ) ) ) || ( ( model . ID ) . ToString ( ) . ToLower ( ) . Contains ( search . ToLower ( ) ) ) )
55+ {
56+ return true ;
57+ }
58+ }
59+ return false ;
60+ }
3161 }
3262}
0 commit comments