/// <summary> /// Initializes a new instance of the <see cref="TransactionDetailsViewModel"/> class. /// </summary> /// <param name="validator">Validator for view model data.</param> /// <param name="accountsVM">Accounts view model.</param> /// <param name="categoriesVM">Categories view model.</param> public TransactionDetailsViewModel(IValidator validator, IAccountsViewModel accountsVM, ICategoriesViewModel categoriesVM) : base(validator) { this.accountsVM = accountsVM; this.categoriesVM = categoriesVM; var accounts = new BindableCollection <AccountDTO>(); accountsCollectionViewSource.Source = accounts; this.accountsVM.Reloaded += (sender, args) => { accounts.Clear(); foreach (var account in this.accountsVM.Accounts) { accounts.Add(account as AccountDTO); } if (!accountsCollectionViewSource.View.IsEmpty) { accountsCollectionViewSource.View.MoveCurrentToFirst(); } }; var categories = new BindableCollection <CategoryDTO>(); categoriesCollectionViewSource.Source = categories; this.categoriesVM.Reloaded += (sender, args) => { categories.Clear(); categories.AddRange(this.categoriesVM.Categories); if (!categoriesCollectionViewSource.View.IsEmpty) { categoriesCollectionViewSource.View.MoveCurrentToFirst(); } }; categoryFilter = (search, item) => { if (string.IsNullOrEmpty(search)) { return(true); } if (item is CategoryDTO) { string searchToLower = search.ToLower(CultureInfo.InvariantCulture); return((item as CategoryDTO).Name.ToLower(CultureInfo.InvariantCulture).Contains(searchToLower)); } return(false); }; }
/// <summary> /// Initializes a new instance of the <see cref="MoneyTrackerViewModel"/> class. /// </summary> public MoneyTrackerViewModel( IAccountsViewModel accountsVM, ICategoriesViewModel categoriesVM, ITransactionsViewModel transactionsVM, ITransactionDetailsViewModel transactionDetailsVM, ITransferViewModel transferViewModel) { Accounts = accountsVM; Categories = categoriesVM; Transactions = transactionsVM; AddNew = transactionDetailsVM; Transfer = transferViewModel; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); _dataContext = App.ServiceProvider.GetService <ICategoriesViewModel>(); await _dataContext.Initialization(); }