Skip to content

Instantly share code, notes, and snippets.

@amr-swalha
Created July 18, 2019 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amr-swalha/84bdad35e22db429d50350a232f0e752 to your computer and use it in GitHub Desktop.
Save amr-swalha/84bdad35e22db429d50350a232f0e752 to your computer and use it in GitHub Desktop.
FeedSearchHandler Example
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace MobileApp.Controls
{
public class FeedSearchHandler : SearchHandler
{
protected override void OnQueryChanged(string oldValue, string newValue)
{
base.OnQueryChanged(oldValue, newValue);
if (string.IsNullOrEmpty(newValue))
{
ItemsSource = null;
}
else
{
var results = new List<Results>();
results.Add(new Results { Text = "First Item", Description = "Hello" });
results.Add(new Results { Text = "Second Item", Description = "Description" });
var data = results.Where(x => x.Text.Trim().ToLower().Contains(newValue.Trim().ToLower())).ToList();
ItemsSource = data;
}
}
protected override void OnItemSelected(object item)
{
base.OnItemSelected(item);
Debug.WriteLine(item.ToString());
}
}
public class Results
{
public string Text { get; set; }
public string Description { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment