private void SetCategory (Category category) { CurrentCategory = category; Name = CurrentCategory.Name; if (CurrentCategory.ParentId != null) { var parentCategory = App.Settings.Categories.GetCategoryById (CurrentCategory.ParentId.Value); CanGoBack = true; ParentName = parentCategory.Name; } else { CanGoBack = false; } if (SubCategories != null && SubCategories.Count != 0) { foreach (var item in SubCategories) { item.Deleted -= OnSubCategoryDeleted; } } var categories = App.Settings.Categories.GetChildCategories (category.Id.Value); SubCategories = new ObservableCollection<CategoryViewModel> (categories.Select (c => new CategoryViewModel (c))); foreach (var item in SubCategories) { item.Deleted += OnSubCategoryDeleted; } }
public SelectCategoryViewModel (Category category) { category = category ?? App.Settings.Categories.GetDefaultCategory (); SetCategory (category); AddSubCategoryCommand = new Command (AddSubCategoryExecute); GoBackCommand = new Command (GoBackCommandExecute); }
public CategoryViewModel (Category category) { Model = category; DeleteCommand = new Command (DeleteCommandExecute); }