private void DeleteCategory(PhraseCategoryViewModel category)
        {
            if (category.Fixed)
            {
                ErrorMessage.Show("The phrase category '{0}' is required by the system, and cannot be deleted.", category.Category);
                return;
            }

            if (this.Question(String.Format("Are you sure you want to delete the phrase category \"{0}\"?", category.Category), "Delete category?"))
            {
                RegisterPendingChange(new DeletePhraseCategoryCommand(category.Model));
                category.IsDeleted = true;
            }
        }
        private void ListPhrases(PhraseCategoryViewModel category)
        {
            if (category != null)
            {
                if (!_phraseCache.ContainsKey(category))
                {
                    var model = new ObservableCollection <PhraseViewModel>(Service.GetPhrases(category.CategoryID).ConvertAll <PhraseViewModel>((p) => new PhraseViewModel(p)));
                    _phraseCache[category] = model;
                }

                lvwPhrases.ItemsSource = _phraseCache[category];
            }
            else
            {
                lvwPhrases.ItemsSource = null;
            }
        }
        private void ShowCategoryContextMenu()
        {
            PhraseCategoryViewModel category = CurrentCategory;

            if (category == null)
            {
                return;
            }

            ContextMenu menu = new ContextMenu();

            MenuItemBuilder builder = new MenuItemBuilder();

            menu.Items.Add(builder.New("Delete Category").Handler(() => { DeleteCategory(category); }).MenuItem);
            menu.Items.Add(builder.New("Add New Category").Handler(() => { AddPhraseCategory(); }).MenuItem);
            lvwCategories.ContextMenu = menu;
        }
 private void lvwCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     CurrentCategory = lvwCategories.SelectedItem as PhraseCategoryViewModel;
     ListPhrases(CurrentCategory);
 }