Hi, Guys. Someone can explain me how search value in Listview ?
My XAML is:
My Code Behind is:
My Device is:
Thanks,
hi @tecomunico
Yes. AllDevice is null because you do not set it. It is just initialized at the beginning.
I see two options. Modify your code and:
1) Use AllDevice instead of allDevice while deserializing recevied data.
2) Define allDevice in class not in LoadAll method and change this line:
AllListView.ItemsSource = AllDevice.Where(x => x.UnidadNumero.Contains(searchText)); // <- Upper case A, AllDevice
to
AllListView.ItemsSource = allDevice.Where(x => x.UnidadNumero.Contains(searchText)); // <- Lower case a, allDevice
If I use a Static List, work fine, but when i use:
var allDevice = JsonConvert.DeserializeObject<List>(result);
AllListView.ItemsSource = allDevice;
Don't work.
Glad to hear that it works @tecomunico . Thank you but I am not a guru.
I think that your next question will be "Why ListView doesn't update when data is changed in the current collection?". At that point, before asking a question you need to understand INotifyPropertyChanged interface and ObservableCollection< T > class because List< T > doesn't trigger PropertyChangedEventHandler.
This is a completely new story. Don't waste your time. Don't pull your hair.
Answers
Hi @tecomunico
Use Linq. Linq examples.
For your code:
I didn't test the piece of code. Linq is the point here.
Thanks @kizanlik, but not work.
My Code is:
using System.Net.Http;
using Xamarin.Forms;
using System.MPG.Models;
using System.Collections.Generic;
using System.MPG.Cells;
using Newtonsoft.Json;
using System.Linq;
namespace System.MPG
{
public partial class VerBusquedaPage : ContentPage
{
public List AllDevice = new List();
}
Picture:

Example:
Listview Working: The Listview show 3 Json Fields, yellow field is a Unit Number (UnidadNumero)

Not Show anything:
hi @tecomunico
Yes. AllDevice is null because you do not set it. It is just initialized at the beginning.
I see two options. Modify your code and:
1) Use AllDevice instead of allDevice while deserializing recevied data.
2) Define allDevice in class not in LoadAll method and change this line:
to
If I use a Static List, work fine, but when i use:
var allDevice = JsonConvert.DeserializeObject<List>(result);
AllListView.ItemsSource = allDevice;
Don't work.
Thanks @kizanlik you are a GURU.
Work Fine !!!!!!
Glad to hear that it works @tecomunico . Thank you but I am not a guru.
I think that your next question will be "Why ListView doesn't update when data is changed in the current collection?". At that point, before asking a question you need to understand INotifyPropertyChanged interface and ObservableCollection< T > class because List< T > doesn't trigger PropertyChangedEventHandler.
This is a completely new story. Don't waste your time. Don't pull your hair.
Thanks @kizanlik