Maximize productivity with
30% off* for a limited time
using BOOSTDEV30.
Includes 3- and 5-packs.
*Some exclusions may apply.New Product LaunchBoldDesk: Help desk ticketing software starts at $10 for 3 agents.
Try it for free.
public class SortingFilteringViewModel : INotifyPropertyChanged
{
private string searchText = null;
public ObservableCollection<TaskInfo> Items { get; set; }
public Command<object> FilterCommand { get; set; }
public DataSource FilterDataSource { get; set; }
public SortingFilteringViewModel()
{
FilterCommand = new Command<object>(OnTextChanged);
FilterDataSource = new DataSource();
FilterDataSource.Source = Items;
AddItemDetails();
}
private void OnTextChanged(object obj)
{
searchText = obj as string;
if (FilterDataSource != null)
{
FilterDataSource.Filter = FilterContacts;
FilterDataSource.RefreshFilter();
}
}
private bool FilterContacts(object obj)
{
var taskInfo = obj as TaskInfo;
return (taskInfo.Title.ToLower().Contains(searchText.ToLower())
|| taskInfo.Description.ToLower().Contains(searchText.ToLower()));
}
} |
<sync:SfListView x:Name="listView"
ItemsSource="{Binding Items}"
DataSource="{Binding FilterDataSource}"
Grid.Row="1"
SelectionMode="None"
ItemSpacing="0,5,0,5"
BackgroundColor="#F0F0F0"
ItemSize="120"> |