示例#1
0
        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;
        }
示例#2
0
 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);
     }
 }
示例#3
0
        public static async Task NewFueling(Fueling fueling)
        {
            await AppStorage.Instance.AddFueling(fueling);

            Fuelings.Add(fueling);
        }