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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
            };
        }
コード例 #5
0
        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);
                }
            };
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public TestEditableItemViewModel(IItemsService <AnItem> itemsService, ISelectedItemService <AnItem> selecteItemService)
     : base(itemsService, selecteItemService)
 {
 }
コード例 #8
0
 public ShowItemErrorsWindowCommand(ISelectedItemService selectedItemService)
 {
     selectedItemService = selectedItemService ?? throw new ArgumentNullException(nameof(selectedItemService));
     selectedItemService.SelectedItemChanged += OnSelectedItemChanged;
     Update(selectedItemService.SelectedItem);
 }