Hi I'm pretty new in the Xamarin Forms world and I'm trying to have the listView that I created refresh its content when the itemSource change. Right know I have this:
public NearMe ()
{
list=jM.ReadData ();
listView.ItemsSource = list;
listView.ItemTemplate = new DataTemplate(typeof(FilialeCell));
searchBar = new SearchBar {
Placeholder="Search"
};
searchBar.PropertyChanged += (sender, e) => {
TextChanged(searchBar.Text);
};
var stack = new StackLayout { Spacing = 0 };
stack.Children.Add (searchBar);
stack.Children.Add (listView);
Content = stack;
}
public void TextChanged(String text){
if (!String.IsNullOrEmpty (text))
text = text[0].ToString().ToUpper() + text.Substring(1);
var filterSedi = list.Where (filiale => filiale.nome.Contains(text));
List<Filiale> newList = filterSedi.ToList ();
newList = newList.OrderBy (x => x.distanza).ToList();
listView.ItemSource = newList;
}
But this is not working, it gives me a blank page at startup, there is no searchBar and neither the listView element. I think that I can't simply assign a new itemSource is this correct? How can I implement this feature? Thank you for your help in advance.