Ejemplo n.º 1
0
        public void ViewClose(ViewModelBase viewModel)
        {
            if (_openViewModelMapping.ContainsKey(viewModel.GetType()))
            {
                IChildView childView = _openViewModelMapping[viewModel.GetType()];
                DispatcherSynchronizationContext.Post(_ => childView.Close(), null);

                _openViewModelMapping.Remove(viewModel.GetType());
            }
        }
Ejemplo n.º 2
0
        public void ViewShow(ViewModelBase viewModel)
        {
            if (_openViewModelMapping.ContainsKey(viewModel.GetType()))
            {
                ((Window) (_openViewModelMapping[viewModel.GetType()])).Activate();
                return;
            }

            Type viewModelType = viewModel.GetType();

            var childView = ServiceLocator.Current.GetInstance<IChildView>(viewModelType.Name.Replace("ViewModel", "View"));

            childView.DataContext = viewModel;
            childView.Show();
            _openViewModelMapping.Add(viewModel.GetType(), childView);
        }