コード例 #1
0
		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;
			}
		}
コード例 #2
0
		public SelectCategoryViewModel (Category category)
		{
			category = category ?? App.Settings.Categories.GetDefaultCategory ();

			SetCategory (category);

			AddSubCategoryCommand = new Command (AddSubCategoryExecute);
			GoBackCommand = new Command (GoBackCommandExecute);
		}
コード例 #3
0
ファイル: CategoryViewModel.cs プロジェクト: Fitabase/Prox
		public CategoryViewModel (Category category)
		{
			Model = category;

			DeleteCommand = new Command (DeleteCommandExecute);
		}