Exemplo n.º 1
0
 private async void OnOpenProductDetailView(int?productId)
 {
     if (ProductDetailViewModel != null && ProductDetailViewModel.HasChanges)
     {
         var result = _messageDialogService.ShowOkCancelDialog("You have made changes. Navigate away?", "Question");
         if (result == MessageDialogResult.Cancel)
         {
             return;
         }
     }
     ProductDetailViewModel = _productDetailViewModelCreator();
     await ProductDetailViewModel.LoadAsync(productId);
 }
        public void CloseProductDetail(IProductDetailViewModel viewModel)
        {
            var detailRegion = this.regionManager.Regions[RegionNames.DetailRegion];
            var viewToClose  = detailRegion.Views
                               .Cast <FrameworkElement>()
                               .Where(v => v.DataContext == viewModel)
                               .FirstOrDefault();

            if (viewToClose != null)
            {
                var disposableViewToClose = viewToClose as IDisposable;
                if (disposableViewToClose != null)
                {
                    disposableViewToClose.Dispose();
                }

                detailRegion.Remove(viewToClose);

                // TODO: Activate appropriate view
            }
        }
Exemplo n.º 3
0
        public ProductViewModel(
            ILogService logService,
            IDataService dataService,
            IDialogService dialogService,
            IEventAggregator eventAggregator,
            IProductRepository productRepository,
            IProductDetailViewModel productDetailViewModel)
            : base(dialogService)
        {
            _logService             = logService;
            _dataService            = dataService;
            _dialogService          = dialogService;
            _productRepository      = productRepository;
            _productDetailViewModel = productDetailViewModel;
            Products = new ObservableCollection <ProductWrapper>();

            RefreshCommand       = new DelegateCommand(Load, () => !IsBusy);
            NewProductCommand    = new DelegateCommand(OnNewProductExecute, () => !IsBusy);
            DeleteProductCommand = new DelegateCommand <int?>(OnDeleteProductExecute);
            UpdateProductCommand = new DelegateCommand <ProductWrapper>(OnUpdateProductExecute);
            eventAggregator.GetEvent <AfterProductSavedEvent>().Subscribe(OnAfterProductSaved);
        }
Exemplo n.º 4
0
 private void AfterProductDeleted(int productId)
 {
     ProductDetailViewModel = null;
 }