Exemplo n.º 1
0
        private async void AddCategory()
        {
            AddCategoryDialog dialog = new AddCategoryDialog();

            ContentDialogResult result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                if (!String.IsNullOrEmpty(dialog.CategoryName))
                {
                    if (!Categories.Any(c => c.Name == dialog.CategoryName))
                    {
                        Category catToAdd = new Category(dialog.CategoryName);
                        int      catId    = await _itemRepository.AddCategory(catToAdd);

                        catToAdd.Id = catId;
                        Categories.Add(catToAdd);
                        BuildItemList();
                    }
                }
            }
        }
 private async void Add_Click(object sender, RoutedEventArgs e)
 {
     CategoryViewModel.category = new Category();
     AddCategoryDialog md = new AddCategoryDialog(CategoryViewModel);
     await md.ShowAsync();
 }