void CreateCells(bool reload) { if (reload) { App.Fuelings.CollectionChanged -= Fuelings_CollectionChanged; Fuelings.Clear(); } foreach (var fueling in App.Fuelings) { Fuelings.Add(new FuelingCell(fueling)); } App.Fuelings.CollectionChanged += Fuelings_CollectionChanged; }
private void Fuelings_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var item in e.NewItems) { if (item is Fueling fueling) { Fuelings.Add(new FuelingCell(fueling)); } else { Debug.Print($"Unknown item in Fueligs list: {item.GetType()}"); } } } else { CreateCells(true); } }
public static async Task NewFueling(Fueling fueling) { await AppStorage.Instance.AddFueling(fueling); Fuelings.Add(fueling); }