title: Castle Windsor constructor injection in WPF ViewModel
body: <p>I am trying to avoid the anti-pattern of Container.Resolve(). How do I change the following to use contructor injection?</p>
  
  <p>Installers.cs</p>
  
  <pre><code> public void Install(Castle.Windsor.IWindsorContainer container, 
                              Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
          {
  
              container.AddFacility&lt;TypedFactoryFacility&gt;();
  
              container
  
               .Register(Component.For&lt;IData&gt;()
                  .ImplementedBy&lt;Data&gt;().LifeStyle.Singleton)
  
  
  
          }
  </code></pre>
  
  <p>BootStrapper.cs</p>
  
  <pre><code>public class Bootstrapper
      {
          private static volatile IWindsorContainer _theWindsorContainer;
          private static object syncRoot = new Object();
  
          public static IWindsorContainer Container
          {
              get
              {
                  if (_theWindsorContainer == null)
                  {
                      lock (syncRoot)
                      {
                          if (_theWindsorContainer == null)
                          {
                              _theWindsorContainer = new WindsorContainer().Install(FromAssembly.This());
                          }
                      }
                  }
  
                  return _theWindsorContainer;
              }
          }
      }
  </code></pre>
  
  <p>OViewModel.cs</p>
  
  <pre><code>public IData ThisData {get;set;}
  
  public OViewModel()
  {
  
    ThisData= Bootstrapper.Container.Resolve&lt;IData&gt;(); 
    InitializeComponent(); 
  }
  </code></pre>
  
  <p>How do I use Windsor Castle constructor injection to initialize the viewmodel and do constructor injection? Either InitializeComponentdoesn't get called or ThisData is null.</p>