async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var items = await RecipeDataStore.GetAllAsync(true); foreach (var item in items) { Items.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void HandleRecipeTapped(string obj) { SelectedRecipe = RecipeDataStore.GetItemAsync(obj).Result; IsDetailViewVisible = false; IsWebViewVisible = true; RecipeWebViewSource = SelectedRecipe.RecipeUrl; }
public RecipesViewModel() { Title = "Recipes List"; Items = new ObservableCollection <Recipe>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewRecipePage, Recipe>(this, "AddItem", async(obj, item) => { var newItem = item as Recipe; Items.Add(newItem); await RecipeDataStore.AddAsync(newItem); }); }
public RecipeViewModel() { DataStore = new RecipeDataStore(); Title = "Browse Recipes"; Recipes = new ObservableCollection <Recipe>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); reloads = 0; MessagingCenter.Subscribe <NewFoodItemPage, Recipe>(this, "AddItem", async(obj, item) => { var newItem = item; Recipes.Add(newItem); await DataStore.AddItemAsync(newItem); }); }