Shouldn't BootStrapper<T>.DisplayRootView() use IoC?

Jul 9, 2010 at 7:17 PM
Edited Jul 9, 2010 at 7:19 PM

Having a look through the source, it looks like DisplayRootView() news up a WindowManager to show the root view model when using WPF. Shouldn't there a call to the container instead? i.e.

protected override void DisplayRootView() 
    var viewModel = IoC.Get<TRootModel>();
    var view = ViewLocator.LocateForModel(viewModel, null, null);
    ViewModelBinder.Bind(viewModel, view, null);

    var activator = viewModel as IActivate;
    if (activator != null)

    Application.Current.RootVisual = view;

Jul 9, 2010 at 7:57 PM
Technically, yes. But, since there's no IoC container built-in, such a call could conceivably fail. I wasn't quite decided on what to do. I could wrap in a try/catch and if no IWindowManager can be instantiated, I could then create the default and use it. Thoughts?
Jul 9, 2010 at 8:28 PM
Makes sense. And what about taking a step forward and establishing a simple convention in IoC, falling back to "DefaultMyComponent" if a request for "IMyComponent" is unsatisfied?
Jul 9, 2010 at 9:19 PM
I suppose that would work. You could always add a TryGet() method BootStrapper which would return null if the service couldn't be located. Then again, it's easy for me to override DisplayRootView and do it myself. So, maybe it's just not a problem?