Ejemplo n.º 1
0
        async Task RefreshData()
        {
            IsBusy = true;
            IsBusy = true;
            var dishes = await _db.GetDishesAsync();

            Items.Clear();
            foreach (var dish in dishes)
            {
                Items.Add(dish);
            }
            IsBusy = false;
            await Task.Delay(2000);

            IsBusy = false;
        }
Ejemplo n.º 2
0
        public SqliteDemoPageViewModel()
        {
            var path = DependencyService.Get <IPathService>().GetDatabasePath();

            _db = new SqliteDataBase(path);
            RefreshDataCommand = new Command(
                async() => await RefreshData());
            AddCommand = new Command(
                async() => await AddData());

            var t = _db.GetDishesAsync();

            t.Wait();
            var dishes = t.Result;

            Items = new ObservableCollection <Dish>(dishes);
        }