public CategoriesPage() { resources = ResourceLoader.GetForCurrentView(); InitializeComponent(); viewModel = new CategoriesPageViewModel(new CategoryService(), new WalletCategoryService()); DataContext = viewModel; }
public CategoriesPage() { var categoryStore = new CategoryStore(); var pageService = new PageService(); ViewModel = new CategoriesPageViewModel(categoryStore, pageService); InitializeComponent(); }
public ActionResult Categories() { NorthwindDb db = new NorthwindDb(_connectionString); CategoriesPageViewModel vm = new CategoriesPageViewModel { Categories = db.GetCategories() }; return(View(vm)); }
private void InitializeViewModel() { _viewModel = new CategoriesPageViewModel() { AddCommand = new Command( () => OpenDetails(new CategoryViewModel() { UserId = GlobalVariables.UserId }, true)), AddChildCommand = new TreeViewSelectedItemCommand <CategoryViewModel>(TreeViewCategories, (item) => OpenDetails(new CategoryViewModel() { UserId = GlobalVariables.UserId, ParentCategoryId = item.Id, RecordType = item.RecordType, IsActive = item.IsActive }, true)), EditCommand = new TreeViewSelectedItemCommand <CategoryViewModel>(TreeViewCategories, (item) => OpenDetails(item), null, true), DeleteCommand = new TreeViewSelectedItemCommand <CategoryViewModel>(TreeViewCategories, (item) => EntityViewHelper.ConfirmAndRemoveNamed(_service, item, () => { // remove in collection _viewModel.Categories.RemoveDescendant(item); NotifyDataChanged(); }), (item) => item.Children.Count == 0), ChangeActivityCommand = new TreeViewSelectedItemCommand <CategoryViewModel>(TreeViewCategories, (item) => { // change activity item.IsActive = !item.IsActive; // save to database _service.Update(item); // reload data Reload(); NotifyDataChanged(); }), ExpandAllCommand = new Command(() => _viewModel.Categories.ExpandAllMain(true)), CollapseAllCommand = new Command(() => _viewModel.Categories.ExpandAllMain(false)) }; this.DataContext = _viewModel; }
public async Task <IActionResult> Index() { var categories = await _context.Categories.Include(i => i.Parent).Include(i => i.CategoryType).Include(i => i.Childs).ToListAsync(); var categoryTypes = await _context.CategoryTypes.ToListAsync(); var model = new CategoriesPageViewModel { CategoryTypes = categoryTypes, Categories = categories }; return(View(model)); }
/// <summary>OnNavigatedTo</summary> /// <param name="e">Navigation Event Args</param> protected override void OnNavigatedTo( NavigationEventArgs e) => DataContext = new CategoriesPageViewModel( SpotifySdk.Instance.Client);
public CategoriesPage() { InitializeComponent(); vm = new CategoriesPageViewModel(); BindingContext = vm; }
private CategoriesPageViewModel GetViewModel() { var viewmodel = new CategoriesPageViewModel(this.fitDataService, null); return(viewmodel); }