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; } }
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(); } }