public EditableMasterDetailViewModel(ISelectedItemService <TItem> selectedItemService) { _selectedItemService = selectedItemService; SaveCommand = new RelayCommand(EndEdit, () => IsEditMode); CancelEditModeCommand = new RelayCommand(CancelEdit, () => IsEditMode); EditModeCommand = new RelayCommand(BeginEdit, () => IsReadMode); RefreshCommand = new RelayCommand(OnRefresh); AddCommand = new RelayCommand(OnAdd, () => IsReadMode); }
public ContentViewModel(IItem rootItem, IServiceProvider serviceProvider) { rootItem = rootItem ?? throw new ArgumentNullException(nameof(rootItem)); ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _selectedItemService = serviceProvider.GetRequiredService <ISelectedItemService>(); var itemViewModelBuilder = ServiceProvider.GetRequiredService <IItemViewModelBuilder>(); RootItems.Add(itemViewModelBuilder.Build(rootItem)); }
public MasterDetailViewModel(IItemsService <TItem> itemsService, ISelectedItemService <TItem> selectedItemService) { _itemsService = itemsService ?? throw new ArgumentNullException(nameof(itemsService)); _selectedItemService = selectedItemService ?? throw new ArgumentNullException(nameof(selectedItemService)); _itemsService.Items.CollectionChanged += (sender, e) => { RaisePropertyChanged(nameof(ItemsViewModels)); }; RefreshCommand = new DelegateCommand(OnRefresh); AddCommand = new DelegateCommand(OnAdd); }
public BookDetailViewModel(IItemsService <Book> itemsService, ISelectedItemService <Book> selectedItemService, INavigationService navigationService, IMessageService messageService, ILogger <BookDetailViewModel> logger) : base(itemsService, selectedItemService) { _itemsService = itemsService ?? throw new ArgumentNullException(nameof(itemsService)); _selectedItemService = selectedItemService ?? throw new ArgumentNullException(nameof(selectedItemService)); _navigationService = navigationService ?? throw new ArgumentNullException(nameof(navigationService)); _messageService = messageService ?? throw new ArgumentNullException(nameof(messageService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _selectedItemService.SelectedItemChanged += (sender, book) => { Item = book; }; }
public BooksViewModel(IItemsService <Book> booksService, ISelectedItemService <Book> selectedBookService, INavigationService navigationService) : base(booksService, selectedBookService) { _booksService = booksService ?? throw new ArgumentNullException(nameof(booksService)); _navigationService = navigationService ?? throw new ArgumentNullException(nameof(navigationService)); EventAggregator <NavigationInfoEvent> .Instance.Event += (sender, e) => { _navigationService.UseNavigation = e.UseNavigation; }; PropertyChanged += async(sender, e) => { if (_navigationService.UseNavigation && e.PropertyName == nameof(SelectedItem) && _navigationService.CurrentPage == PageNames.BooksPage) { await _navigationService.NavigateToAsync(PageNames.BookDetailPage); } }; }
public EditableItemViewModel(IItemsService <TItem> itemsService, ISelectedItemService <TItem> selectedItemService) { _itemsService = itemsService ?? throw new ArgumentNullException(nameof(itemsService)); _selectedItemService = selectedItemService ?? throw new ArgumentNullException(nameof(selectedItemService)); Item = _selectedItemService.SelectedItem; PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(Item)) { RaisePropertyChanged(nameof(EditItem)); } }; EditCommand = new DelegateCommand(BeginEdit, () => IsReadMode); CancelCommand = new DelegateCommand(CancelEdit, () => IsEditMode); SaveCommand = new DelegateCommand(EndEdit, () => IsEditMode); AddCommand = new DelegateCommand(OnAdd, () => IsReadMode); DeleteCommand = new DelegateCommand(OnDelete); }
public TestEditableItemViewModel(IItemsService <AnItem> itemsService, ISelectedItemService <AnItem> selecteItemService) : base(itemsService, selecteItemService) { }
public ShowItemErrorsWindowCommand(ISelectedItemService selectedItemService) { selectedItemService = selectedItemService ?? throw new ArgumentNullException(nameof(selectedItemService)); selectedItemService.SelectedItemChanged += OnSelectedItemChanged; Update(selectedItemService.SelectedItem); }