protected async void OnEditItem(ItemRowViewModel item) { AddEditItemViewModel vm = new AddEditItemViewModel(KeyboardMode, item.Id, item.Type, true) { Name = item.Name, Amount = item.Amount.ToString(CultureInfo.CurrentCulture), }; AddEditItemDialog dialog = new AddEditItemDialog() { DataContext = vm, }; await dialog.ShowAsync(); switch (dialog.Result) { case AddEditItemDialogResult.Save: SaveItem(vm); break; case AddEditItemDialogResult.Delete: Delete(vm); break; default: break; } }
protected override void OnNewItem(ItemType itemType) { if (_addEditItemDialog == null) { _addEditItemDialog = new AddEditItemDialog(KeyboardMode, itemType, false); _addEditItemDialog.OnError += AddEditItemDialog_OnError; _addEditItemDialog.Show(); WaitForAddEditItemResult(); } }
private async void CloseAddEditItemDialog() { try { _addEditItemDialog = null; await Navigation.PopModalAsync(); } catch (Exception e) { HandleError(e); } }
private void OnEditCommand(ItemRowViewModel item) { try { if (_addEditItemDialog == null) { _addEditItemDialog = new AddEditItemDialog(KeyboardMode, item.Id, item.Type, true, item.Name, item.Amount.ToString(CultureInfo.CurrentCulture)); _addEditItemDialog.OnError += AddEditItemDialog_OnError; _addEditItemDialog.Show(); WaitForAddEditItemResult(); } } catch (Exception e) { HandleError(e); } }
public async Task AddItemAsync() { var viewModel = new AddEditItemDialogViewModel(); viewModel.editedItem = new Item(); viewModel.itemGroups = _contentProviderApiService.GetItemGroups(); AddEditItemDialog dialog = new AddEditItemDialog(viewModel); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { // mentes var itemGroup = dialog.ViewModel.selectedItemGroup; itemGroup.itemList.Add(dialog.ViewModel.editedItem); // lista frissites _contentProviderApiService.SaveData(); } }
protected override async void OnNewItem(ItemType itemType) { AddEditItemViewModel vm = new AddEditItemViewModel(KeyboardMode, itemType, false); AddEditItemDialog dialog = new AddEditItemDialog() { DataContext = vm, }; await dialog.ShowAsync(); switch (dialog.Result) { case AddEditItemDialogResult.Save: SaveItem(vm); break; default: break; } }
public async Task EditItemAsync() { var adf = _contentProviderApiService.getItemGroupForItem(_item); var viewModel = new AddEditItemDialogViewModel(); viewModel.editedItem = Item; viewModel.itemGroups = _contentProviderApiService.GetItemGroups(); var itemGroup = _contentProviderApiService.getItemGroupForItem(Item); viewModel.selectedItemGroup = itemGroup; AddEditItemDialog dialog = new AddEditItemDialog(viewModel); ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { itemGroup.itemList.Remove(Item); viewModel.selectedItemGroup.itemList.Add(Item); _contentProviderApiService.SaveData(); } }
private void AddEditItemDialog_OnError(object sender, System.IO.ErrorEventArgs e) { _addEditItemDialog = null; HandleError(e.GetException()); }