I am a full beginner this is my code, i appreciate if i can have a sample code different to the xample that its in essential studio becouse its to dificult to understand
<StackLayout Orientation="Horizontal">
<SearchBar x:Name="filterText"
Grid.Row="0"
Grid.Column="0"
IsVisible="true"
Placeholder="Search here to filter"
TextChanged="OnFilterTextChanged">
</SearchBar>
</StackLayout>
<listView:SfListView x:Name="listView" >
</listView:SfListView>
public TestPageList()
{
InitializeComponent();
listView.ItemTemplate = new DataTemplate(typeof(GameCell));
listView.ItemSize = 60;
LoadGames();
}
SearchBar searchBar = null;
private void OnFilterTextChanged(object sender, TextChangedEventArgs e)
{
searchBar = (sender as SearchBar);
if (listView.DataSource != null)
{
listView.DataSource.Filter = FilterGames;
listView.DataSource.RefreshFilter();
}
}
private bool FilterGames(object obj)
{
if (searchBar == null || searchBar.Text == null)
return true;
var taskInfo = obj as StatGame;
if (taskInfo.YourDeck.ToLower().Contains(searchBar.Text.ToLower())
|| taskInfo.YourDeck.ToLower().Contains(searchBar.Text.ToLower()))
return true;
else
return false;
}
private IList<StatGame> list()
{
using (var da = new DataAccess())
{
var list = da.GetList<StatGame>(true).ToList();
return list;
}
}
private void LoadGames()
{
using (var da = new DataAccess())
{
var list = da.GetList<StatGame>(true).ToList();
var total = list.Sum(l => l.MyResult);
listView.ItemsSource = list;
listView.ItemSize = 60;
}
}
Note: StatGame its a SQLite table class.