protected ViewModelBaseWrapper GetViewModel(ViewModelConnection item)
        {
            Type type = item.ViewModelType;
            ViewModelBaseWrapper viewModel = (ViewModelBaseWrapper)_iocManager.Resolve(item.ViewModelType);

            return(viewModel);
        }
        public void RegisterViewModel <VM, V>()
            where VM : ViewModelBase
            where V : ContentControl
        {
            var item = new ViewModelConnection();

            item.Set <VM, V>();
            _views.Add(item);

            _iocManager.RegisterType <VM>();
        }
        public void OpenViewBlocking(Type VM, ContentControl control = null, Parameter parameter = null)
        {
            if (control != null)
            {
                if (control.DataContext as ViewModelBaseWrapper != null)
                {
                    (control.DataContext as ViewModelBaseWrapper).NavigatedFrom();
                }
            }

            // Get item for passed viewModel type
            ViewModelConnection item = _views.FirstOrDefault(x => x.ViewModelType == VM);

            if (item == null)
            {
                throw new Exception("View not registered.");
            }

            ContentControl view = GetView(item);

            ViewModelBaseWrapper viewModel = view.DataContext as ViewModelBaseWrapper;

            if (viewModel == null)
            {
                viewModel = GetViewModel(item);
            }

            if (control == null)
            {
                view.DataContext = viewModel;
                _content.Content = view;
            }
            else
            {
                view.DataContext = viewModel;
                control.Content  = view;
            }

            viewModel.Parameters = parameter;
            viewModel.NavigatedTo();
        }
 protected ContentControl GetView(ViewModelConnection item) => Activator.CreateInstance(item.ViewType) as ContentControl;