T IViewModelService.CreateViewForViewModel <T>(object viewModel) { Type viewModelType = viewModel.GetType(); IViewFactory factory = this.UIElementFactories.FirstOrDefault(f => f.Metadata.ViewModelType == viewModelType)?.Value; if (factory != null) { T view = (T)factory.CreateInstance(); this.Container.SatisfyImportsOnce(view); this.Container.SatisfyImportsOnce(viewModel); view.DataContext = viewModel; return(view); } Debug.Fail("No view registered for view model of type '{0}'!", viewModelType.Name); return(null); }