public MainViewModel(IDependencyService serviceLocator) { this.serviceLocator = serviceLocator; SearchCriteria = new ObservableCollection <SearchCriteriaViewModel>() { new SearchCriteriaViewModel { Field = "Year", Operator = ComparisonOperation.GreaterEqual, Value = "2000" } }; Search = new AsyncDelegateCommand(OnSearch, () => SearchCriteria.Count > 0); EditSearchCriteria = new AsyncDelegateCommand <SearchCriteriaViewModel>(OnEditSearchCriteria); CancelSearch = new DelegateCommand(OnCancelSearch, () => cancellationTokenSource != null); AddSearchCriteria = new AsyncDelegateCommand(OnAddSearchCriteria); MessagingCenter.Subscribe <SearchCriteriaViewModel>(this, "Delete", async scvm => { SearchCriteria.Remove(scvm); if (SearchCriteria.Count == 0) { Search.RaiseCanExecuteChanged(); } await serviceLocator.Get <INavigationService>().GoBackAsync(); }); }
public MainViewModel(IDependencyService serviceLocator) { this.serviceLocator = serviceLocator; Quotes = new ObservableCollection <QuoteViewModel>(QuoteManager.Load(serviceLocator.Get <IQuoteLoader>()) .Select(q => new QuoteViewModel(q))); SelectedQuote = Quotes.FirstOrDefault(); AddQuote = new AsyncDelegateCommand(OnAddQuote); DeleteQuote = new AsyncDelegateCommand <QuoteViewModel>(OnDeleteQuote); EditQuote = new AsyncDelegateCommand <QuoteViewModel>(OnEditQuote); ShowQuoteDetail = new AsyncDelegateCommand <QuoteViewModel>(OnShowQuoteDetails); }
public MainViewModel(IDependencyService serviceLocator) { this.serviceLocator = serviceLocator; GetContact(); Contact unContact = new Contact(); Contacts = new ObservableCollection <ContactViewModel>(ListContacts .Select(c => new ContactViewModel(c))); SelectedContact = Contacts.FirstOrDefault(); AddContact = new AsyncDelegateCommand(OnAddContact); DeleteContact = new AsyncDelegateCommand <ContactViewModel>(OnDeleteContact); EditContact = new AsyncDelegateCommand <ContactViewModel>(OnEditContact); ShowContactDetail = new AsyncDelegateCommand <ContactViewModel>(OnShowContactDetails); }