Created
July 18, 2019 03:24
-
-
Save amr-swalha/84bdad35e22db429d50350a232f0e752 to your computer and use it in GitHub Desktop.
FeedSearchHandler Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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