I have a listView where the cells have a field that is constantly updated on the backend. I have a timer set up to pull the new data at a set interval, but I don't see anywhere to have the listView refresh itself. For an iOS project I would simply call tableView.ReloadData(). I've tried reassigning the listView.ItemSource property on the main thread, but that didn't work.
I've also tried looking into bindings/observable collections, but those only seem to work for adding/removing items from the list. The number of items in my list aren't going to change, just a property on each item.
Here's a simplified version of the code I'm attempting:
public class Foo {
List<MyItem> itemList;
ListView listView;
public Foo () {
itemList = new List<MyItem>();
listView = new ListView();
listView.ItemTemplate = new DataTemplate (typeof(MyCell));
listView.ItemsSource = itemList;
var timer = new Timer (2000);
timer.Elapsed += OnTimerElapsed;
timer.Start ();
}
public void OnTimerElapsed(object o, ElapsedEventArgs e) {
Device.BeginInvokeOnMainThread (() => {
itemList = beaconLocater.GetAvailableBeacons();
listView.ItemsSource = itemList;
});
}
}